[Bug #21986] Fix location of numeric literal

When checking for suffixes, do not flush the numeric literal token
even if no suffix is found.
This commit is contained in:
Nobuyoshi Nakada 2026-04-09 13:16:57 +09:00
parent f4b5566d09
commit 4644e4f2fa
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2026-04-09 05:06:02 +00:00
2 changed files with 8 additions and 1 deletions

View File

@ -8927,7 +8927,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);

View File

@ -1751,6 +1751,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