diff options
author | tompng <[email protected]> | 2024-10-05 15:18:45 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-10-05 15:59:01 +0900 |
commit | 6743e6285a585fbd0a3b25b8eeed10caf1fae66e (patch) | |
tree | d563fe63b848a747678818e3704c795ebbea1166 | |
parent | e939f28cc93a538e751c9c1200c95c4c85c9d09b (diff) |
[Bug #20784] Fix incomplete character syntax followed by EOF
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11805
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | test/ripper/test_scanner_events.rb | 4 |
2 files changed, 5 insertions, 1 deletions
@@ -10118,7 +10118,7 @@ parse_qmark(struct parser_params *p, int space_seen) enc = rb_utf8_encoding(); tokadd_utf8(p, &enc, -1, 0, 0); } - else if (!ISASCII(c = peekc(p))) { + else if (!ISASCII(c = peekc(p)) && c != -1) { nextc(p); if (tokadd_mbchar(p, c) == -1) return 0; } diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index 261e259889..ed291c4384 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -952,6 +952,10 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase scan('CHAR', "?\\u{41}") err = nil + assert_equal [], scan('CHAR', '?\\') {|*e| err = e} + assert_equal([:on_parse_error, "Invalid escape character syntax", "?\\"], err) + + err = nil assert_equal [], scan('CHAR', '?\\M ') {|*e| err = e} assert_equal([:on_parse_error, "Invalid escape character syntax", "?\\M "], err) |