Skip to content

fix: Remap float parts as integers when parsed as indices #12185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ fn name_ref_or_index(p: &mut Parser) {
p.at(IDENT) || p.at(INT_NUMBER) || p.at(FLOAT_NUMBER_PART) || p.at_ts(FLOAT_LITERAL_FIRST)
);
let m = p.start();
if p.at_ts(FLOAT_LITERAL_FIRST) {
p.bump_remap(FLOAT_NUMBER_PART);
if p.at(FLOAT_NUMBER_PART) || p.at_ts(FLOAT_LITERAL_FIRST) {
p.bump_remap(INT_NUMBER);
} else {
p.bump_any();
}
Expand Down
6 changes: 3 additions & 3 deletions crates/parser/test_data/parser/inline/ok/0011_field_expr.rast
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SOURCE_FILE
IDENT "x"
DOT "."
NAME_REF
FLOAT_NUMBER_PART "0"
INT_NUMBER "0"
DOT "."
WHITESPACE " "
NAME_REF
Expand All @@ -67,10 +67,10 @@ SOURCE_FILE
IDENT "x"
DOT "."
NAME_REF
FLOAT_NUMBER_PART "0"
INT_NUMBER "0"
DOT "."
NAME_REF
FLOAT_NUMBER_PART "1"
INT_NUMBER "1"
SEMICOLON ";"
WHITESPACE "\n "
EXPR_STMT
Expand Down