Skip to content

Commit

Permalink
Merge pull request #2850 from ruby/fix-line-continuation
Browse files Browse the repository at this point in the history
Fix line continuation heredoc dedent calculation
  • Loading branch information
kddnewton authored May 28, 2024
2 parents 3a47afe + 63b596d commit 833df96
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -12367,9 +12367,10 @@ parser_lex(pm_parser_t *parser) {

// If we are immediately following a newline and we have hit the
// terminator, then we need to return the ending of the heredoc.
if (!line_continuation && current_token_starts_line(parser)) {
if (current_token_starts_line(parser)) {
const uint8_t *start = parser->current.start;
if (start + ident_length <= parser->end) {

if (!line_continuation && (start + ident_length <= parser->end)) {
const uint8_t *newline = next_newline(start, parser->end - start);
const uint8_t *ident_end = newline;
const uint8_t *terminator_end = newline;
Expand Down Expand Up @@ -12525,11 +12526,8 @@ parser_lex(pm_parser_t *parser) {
}

parser->current.end = breakpoint + 1;

if (!was_line_continuation) {
pm_token_buffer_flush(parser, &token_buffer);
LEX(PM_TOKEN_STRING_CONTENT);
}
pm_token_buffer_flush(parser, &token_buffer);
LEX(PM_TOKEN_STRING_CONTENT);
}

// Otherwise we hit a newline and it wasn't followed by
Expand Down

0 comments on commit 833df96

Please sign in to comment.