summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-03-26 09:33:03 -0400
committerKevin Newton <kddnewton@gmail.com>2024-03-26 12:11:09 -0400
commit2a3601d64ead632fb9f0709ac6986a44da76efe3 (patch)
treeae7175d63c610a743660ae5b50317dbd83d65975
parent240fb3957b02cb9a1cc0d1e01ae40db803390bed (diff)
[ruby/prism] Handle regexp split between heredocs
https://github.com/ruby/prism/commit/c1400d8aed
-rw-r--r--prism/prism.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/prism/prism.c b/prism/prism.c
index e97af23676..e02bceed65 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -4345,10 +4345,10 @@ pm_interpolated_string_node_append(pm_parser_t *parser, pm_interpolated_string_n
if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_STATIC_LITERAL)) {
switch (parser->frozen_string_literal) {
case PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED:
- pm_node_flag_set((pm_node_t *) node, PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN);
+ pm_node_flag_set((pm_node_t *) node, PM_INTERPOLATED_STRING_NODE_FLAGS_MUTABLE);
break;
case PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED:
- pm_node_flag_set((pm_node_t *) node, PM_INTERPOLATED_STRING_NODE_FLAGS_MUTABLE);
+ pm_node_flag_set((pm_node_t *) node, PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN);
break;
}
}
@@ -10900,11 +10900,15 @@ parser_lex(pm_parser_t *parser) {
// the list of newlines.
if (parser->heredoc_end == NULL) {
pm_newline_list_append(&parser->newline_list, breakpoint);
+ parser->current.end = breakpoint + 1;
+ breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, false);
+ break;
}
parser->current.end = breakpoint + 1;
- breakpoint = pm_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end, false);
- break;
+ parser_flush_heredoc_end(parser);
+ pm_regexp_token_buffer_flush(parser, &token_buffer);
+ LEX(PM_TOKEN_STRING_CONTENT);
case '\\': {
// If we hit escapes, then we need to treat the next
// token literally. In this case we'll skip past the