Skip to content

Commit

Permalink
Scientific numeric literals take priority over access
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Nov 5, 2024
1 parent b9386d9 commit 609df0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/parser.hera
Original file line number Diff line number Diff line change
Expand Up @@ -6029,7 +6029,7 @@ DecimalBigIntegerLiteral
# https://262.ecma-international.org/#prod-DecimalLiteral
DecimalLiteral
# NOTE: Not matching the dot as part of a number if it is followed by a valid JS identifier so that it will match as a property access
$( /(?:0|[1-9](?:_[0-9]|[0-9])*)(?=\.(?:\p{ID_Start}|[_$]))/ ) ->
$( /(?:0|[1-9](?:_[0-9]|[0-9])*)(?=\.(?:\p{ID_Start}|[_$]))/ ) !( "." ExponentPart ) ->
// Insert an extra dot to make property access work
return $1 + "."
$( /(?:0|[1-9](?:_[0-9]|[0-9])*)(?:\.(?:[0-9](?:_[0-9]|[0-9])*))?/ ExponentPart? )
Expand Down
4 changes: 4 additions & 0 deletions test/numbers.civet
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ describe "numbers", ->
x = 1e2
y = 1e-2
z = 1e+2
w = 1.e2
n = 1.e-2
---
x = 1e2
y = 1e-2
z = 1e+2
w = 1.e2
n = 1.e-2
"""

testCase """
Expand Down

0 comments on commit 609df0f

Please sign in to comment.