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