[ruby/yarp] fix: unterminated % in arguments
https://github.com/ruby/yarp/commit/efb3102369
This commit is contained in:
parent
20106fe227
commit
2800d1fd37
@ -155,6 +155,13 @@ class ErrorsTest < Test::Unit::TestCase
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_unterminated_argument_expression
|
||||||
|
assert_errors expression('a %'), 'a %', [
|
||||||
|
["Unexpected end of input", 2..3],
|
||||||
|
["Expected a value after the operator.", 3..3],
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
def test_1_2_3
|
def test_1_2_3
|
||||||
assert_errors expression("(1, 2, 3)"), "(1, 2, 3)", [
|
assert_errors expression("(1, 2, 3)"), "(1, 2, 3)", [
|
||||||
["Expected to be able to parse an expression.", 2..2],
|
["Expected to be able to parse an expression.", 2..2],
|
||||||
|
12
yarp/yarp.c
12
yarp/yarp.c
@ -6494,13 +6494,11 @@ parser_lex(yp_parser_t *parser) {
|
|||||||
|
|
||||||
// % %= %i %I %q %Q %w %W
|
// % %= %i %I %q %Q %w %W
|
||||||
case '%': {
|
case '%': {
|
||||||
// In a BEG state, if you encounter a % then you must be
|
// If there is no subsequent character then we have an invalid token. We're
|
||||||
// starting something. In this case if there is no
|
// going to say it's the percent operator because we don't want to move into the
|
||||||
// subsequent character then we have an invalid token. We're
|
// string lex mode unnecessarily.
|
||||||
// going to say it's the percent operator because we don't
|
if ((lex_state_beg_p(parser) || lex_state_arg_p(parser)) && (parser->current.end >= parser->end)) {
|
||||||
// want to move into the string lex mode unnecessarily.
|
yp_diagnostic_list_append(&parser->error_list, parser->current.start, parser->current.end, "Unexpected end of input");
|
||||||
if (lex_state_beg_p(parser) && (parser->current.end >= parser->end)) {
|
|
||||||
yp_diagnostic_list_append(&parser->error_list, parser->current.start, parser->current.end, "unexpected end of input");
|
|
||||||
LEX(YP_TOKEN_PERCENT);
|
LEX(YP_TOKEN_PERCENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user