summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-10-11 20:56:33 -0400
committerKevin Newton <kddnewton@gmail.com>2023-10-13 15:31:30 -0400
commite4f1c06a9bb6012ac155b7a7789d2b5cb4e8abdc (patch)
treeb6a6cddb0b5b50f7ee010afbcec5ebc6c25ecf40
parenta1de76296655154e3d8db782721efa230c7b4619 (diff)
[ruby/prism] Use current_string to handle :" symbols
https://github.com/ruby/prism/commit/eedeec8f9a
-rw-r--r--prism/prism.c21
-rw-r--r--test/prism/unescape_test.rb2
2 files changed, 20 insertions, 3 deletions
diff --git a/prism/prism.c b/prism/prism.c
index 34db457054..51afe730aa 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -10946,7 +10946,15 @@ parse_symbol(pm_parser_t *parser, pm_lex_mode_t *lex_mode, pm_lex_state_t next_s
}
// Now we can parse the first part of the symbol.
- pm_node_t *part = parse_string_part(parser);
+ pm_node_t *part;
+ if (match1(parser, PM_TOKEN_STRING_CONTENT)) {
+ pm_token_t opening = not_provided(parser);
+ pm_token_t closing = not_provided(parser);
+ part = (pm_node_t *) pm_string_node_create_current_string(parser, &opening, &parser->current, &closing);
+ parser_lex(parser);
+ } else {
+ part = parse_string_part(parser);
+ }
// If we got a string part, then it's possible that we could transform
// what looks like an interpolated symbol into a regular symbol.
@@ -10963,7 +10971,16 @@ parse_symbol(pm_parser_t *parser, pm_lex_mode_t *lex_mode, pm_lex_state_t next_s
if (part) pm_node_list_append(&node_list, part);
while (!match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
- if ((part = parse_string_part(parser)) != NULL) {
+ if (match1(parser, PM_TOKEN_STRING_CONTENT)) {
+ pm_token_t opening = not_provided(parser);
+ pm_token_t closing = not_provided(parser);
+ part = (pm_node_t *) pm_string_node_create_current_string(parser, &opening, &parser->current, &closing);
+ parser_lex(parser);
+ } else {
+ part = parse_string_part(parser);
+ }
+
+ if (part != NULL) {
pm_node_list_append(&node_list, part);
}
}
diff --git a/test/prism/unescape_test.rb b/test/prism/unescape_test.rb
index 3953d0c78e..123c139077 100644
--- a/test/prism/unescape_test.rb
+++ b/test/prism/unescape_test.rb
@@ -134,7 +134,7 @@ module Prism
[Context::List.new("%I[", "]"), escapes],
[Context::Symbol.new("%s[", "]"), escapes],
[Context::Symbol.new(":'", "'"), escapes],
- # [Context::Symbol.new(":\"", "\""), escapes],
+ [Context::Symbol.new(":\"", "\""), escapes],
# [Context::RegExp.new("/", "/"), escapes],
# [Context::RegExp.new("%r[", "]"), escapes]
]