Skip to content

Commit

Permalink
[ruby/prism] Simplify unterminated string
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Dec 6, 2023
1 parent c8b60c8 commit c5a4409
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions prism/prism.c
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions test/prism/errors_test.rb
Expand Up @@ -149,9 +149,9 @@ def test_unterminated_xstring
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

Expand Down

0 comments on commit c5a4409

Please sign in to comment.