jashkenas/coffeescript

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

lulunac27a opened this issue · 1 comments

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

  • CoffeeScript version: 2.7.0

Changing

coffeescript/src/lexer.coffee

Lines 1314 to 1315 in 817c39a

^ (?:\d+(?:_\d+)*)? \.? \d+(?:_\d+)* # decimal
(?:e[+-]? \d+(?:_\d+)* )?

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.