Skip to content

Commit 3ec0699

Browse files
authored
Fix string delimiter with "@" confused for embedded variable (#1521)
1 parent 9d0af98 commit 3ec0699

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

src/yarp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5801,7 +5801,7 @@ lex_interpolation(yp_parser_t *parser, const uint8_t *pound) {
58015801
// If we didn't get an valid interpolation, then this is just regular
58025802
// string content. This is like if we get "#@-". In this case the caller
58035803
// should keep lexing.
5804-
parser->current.end = variable;
5804+
parser->current.end = pound + 1;
58055805
return YP_TOKEN_NOT_PROVIDED;
58065806
}
58075807
case '$':

test/yarp/errors_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ def test_unterminated_string
152152
]
153153
end
154154

155+
def test_incomplete_instance_var_string
156+
assert_errors expression('%@#@@#'), '%@#@@#', [
157+
["Incomplete instance variable", 4..5],
158+
["Expected a newline or semicolon after the statement", 4..4]
159+
]
160+
end
161+
155162
def test_unterminated_s_symbol
156163
assert_errors expression("%s[abc"), "%s[abc", [
157164
["Expected a closing delimiter for the dynamic symbol", 3..3]

test/yarp/fixtures/strings.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,7 @@
9999
?a "a"
100100

101101
%Q{abc}
102+
103+
%^#$^#
104+
105+
%@#@#

test/yarp/snapshots/strings.txt

Lines changed: 20 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)