You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix exponent notation with a trailing decimal point - #5506
The lexer currently stops before the decimal point in 1.e1 and 1.e-1, producing 1..e1 and 1..e - 1. Recognize a trailing decimal point when it is followed by a valid exponent so these inputs compile as JavaScript numeric literals.
Changes:
Add the exponent form to the source and generated lexer.
Add regression coverage for positive and negative exponents.
Verification:
Generated lib/coffeescript/lexer.js from src/lexer.coffee in an isolated, network-disabled container.
Ran 5 isolated Node assertions: both expressions evaluate to the expected values, both emitted forms retain their numeric literal, and existing 4.toString() behavior remains intact.
git diff --check passed; patch policy accepted 3 text files and 8 changed lines.
You're right: 42.e3 is currently parsed as access to the e3 property, so treating it as a number would change existing behavior. The same ambiguity applies to a signed exponent such as 1.e-1, which can currently be parsed as property access followed by subtraction.
I agree this should not be merged as a bug fix without a compatibility decision. Would you prefer to leave this syntax unsupported and close #5469, or consider the change only for a future breaking release? I'll hold off on further changes pending your preference.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5469
The lexer currently stops before the decimal point in
1.e1and1.e-1, producing1..e1and1..e - 1. Recognize a trailing decimal point when it is followed by a valid exponent so these inputs compile as JavaScript numeric literals.Changes:
Verification:
lib/coffeescript/lexer.jsfromsrc/lexer.coffeein an isolated, network-disabled container.4.toString()behavior remains intact.git diff --checkpassed; patch policy accepted 3 text files and 8 changed lines.