jashkenas / coffeescript

Unfancy JavaScript
https://coffeescript.org/
MIT License
16.51k stars 1.99k forks source link

Number with a dot before `e` in scientific notation returns two dots in JavaScript #5469

Open lulunac27a opened 1 month ago

lulunac27a commented 1 month ago

Choose one: is this a bug report or feature request? Bug report

Input Code

Example code:

1.e1

And another example:

1.e-1

Expected Behavior

1.e1;

and

1.e-1;

Current Behavior

1..e1;

and

1..e - 1;

Possible Solution

Remove a dot or add a 0 after the dot if there is no number after the dot and before the e in scientific notation.

Context

Using scientific notation with decimals

Environment

Inve1951 commented 1 month ago

Changing https://github.com/jashkenas/coffeescript/blob/817c39a13065a900725943c33a79252a69d779e2/src/lexer.coffee#L1314-L1315 to \.? (?:\d+(?:_\d+)+)? on the first line may fix this. I've tried the 1.e-1 syntax in node and firefox and both accept it. Haven't checked the spec.