diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2026-05-11 13:40:35 -0700 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2026-05-11 13:40:35 -0700 |
| commit | 926b0ec4ed0e181735f3778c3e6b79d891e70848 (patch) | |
| tree | eb22f3cb3b0e74cde605dc9c240ed6e32373ac43 | |
| parent | e4271b554c8b13270754a45ee631789237d5cced (diff) | |
merge revision(s) 4644e4f2fafe45e2c49f18bc9712d0f5fff3d341: [Backport #21986]
[PATCH] [Bug #21986] Fix location of numeric literal
When checking for suffixes, do not flush the numeric literal token
even if no suffix is found.
| -rw-r--r-- | parse.y | 1 | ||||
| -rw-r--r-- | test/ruby/test_ast.rb | 8 |
2 files changed, 8 insertions, 1 deletions
@@ -8959,7 +8959,6 @@ number_literal_suffix(struct parser_params *p, int mask) } if (!ISASCII(c) || ISALPHA(c) || c == '_') { p->lex.pcur = lastp; - literal_flush(p, p->lex.pcur); return 0; } pushback(p, c); diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index 8ab5c14eca..b54c8f3a10 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -1739,6 +1739,14 @@ dummy assert_locations(node.children.last.locations, [[1, 0, 1, 2]]) end + def test_numeric_location_with_nonsuffix + node = ast_parse("1if true") + assert_locations(node.children.last.children[1].locations, [[1, 0, 1, 1]]) + + node = ast_parse("1q", error_tolerant: true) + assert_locations(node.children.last.locations, [[1, 0, 1, 1]]) + end + private def ast_parse(src, **options) begin |
