summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-12-06 15:52:26 -0500
committergit <svn-admin@ruby-lang.org>2023-12-06 21:34:48 +0000
commitc5a4409f20e816d3777ebd2c23b894022342a975 (patch)
treeadb3dec82f8ff0c02a5995841c2d96ec089980d5
parentc8b60c8ac2c8bbd077150792b5b207e983ab3634 (diff)
[ruby/prism] Simplify unterminated string
https://github.com/ruby/prism/commit/ef512ca914
-rw-r--r--prism/prism.c4
-rw-r--r--test/prism/errors_test.rb4
2 files changed, 4 insertions, 4 deletions
diff --git a/prism/prism.c b/prism/prism.c
index 7eeed37ade..15195ea5cd 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -13594,10 +13594,10 @@ parse_strings(pm_parser_t *parser, pm_node_t *current) {
pm_string_t unescaped = parser->current_string;
parser_lex(parser);
- if (match1(parser, PM_TOKEN_STRING_END)) {
+ if (match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
node = (pm_node_t *) pm_string_node_create_unescaped(parser, &opening, &content, &parser->current, &unescaped);
node->flags |= parse_unescaped_encoding(parser);
- parser_lex(parser);
+ expect1(parser, PM_TOKEN_STRING_END, PM_ERR_STRING_LITERAL_TERM);
} else if (accept1(parser, PM_TOKEN_LABEL_END)) {
node = (pm_node_t *) pm_symbol_node_create_unescaped(parser, &opening, &content, &parser->previous, &unescaped);
} else {
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb
index f5c4c1813a..906dbac594 100644
--- a/test/prism/errors_test.rb
+++ b/test/prism/errors_test.rb
@@ -149,9 +149,9 @@ module Prism
def test_unterminated_interpolated_string
expr = expression('"hello')
assert_errors expr, '"hello', [
- ["expected a closing delimiter for the interpolated string", 0..1]
+ ["expected a closing delimiter for the string literal", 6..6]
]
- assert_equal expr.parts[0].unescaped, "hello"
+ assert_equal expr.unescaped, "hello"
assert_equal expr.closing, ""
end