From 609df0ff8d2a12bb005344acb91784b3c39d7a48 Mon Sep 17 00:00:00 2001 From: Erik Demaine Date: Tue, 5 Nov 2024 11:47:14 -0500 Subject: [PATCH] Scientific numeric literals take priority over access --- source/parser.hera | 2 +- test/numbers.civet | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/parser.hera b/source/parser.hera index d4f4766e..6d88ee33 100644 --- a/source/parser.hera +++ b/source/parser.hera @@ -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? ) diff --git a/test/numbers.civet b/test/numbers.civet index 14ddc88a..ffa790d3 100644 --- a/test/numbers.civet +++ b/test/numbers.civet @@ -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 """