Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringNumericLiteral does not include NumericLiteralSeparator #10938

merged 1 commit into from Jan 10, 2020


Copy link

JLHwung commented Dec 29, 2019

Q                       A
Fixed Issues? proposal-numeric-separator incorrectly removes _ in Number argument.
Patch: Bug Fix? Yes, but given that it does change the behaviour, minor is expected.
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link Nope, Number("4_2") is never mentioned in the docs.
License MIT

The String Type Interpretation Grammar of ToNumber was updated in tc39/proposal-numeric-separator@fc53cdb, the StringNumericLiteral does not allow a NumericLiteralSeparator. Therefore the following example should return NaN

new Number("4_2")

but Babel will transform Number("4_2") into Number("42"), which is incorrect.
This PR removes the transformation on Number arguments.

Copy link

nicolo-ribaudo left a comment

Out of curiosity, did you find this in a bug report outside of GitHub?


This comment has been minimized.

Copy link
Contributor Author

JLHwung commented Dec 29, 2019

@nicolo-ribaudo Nope. I find it by searching CallExpression: in the code base.

Background: I was reviewing an estree AST design PR and inspired from (prevent GitHub backtrace)

It's a severe concern that non-optional member accesses and function calls are getting two different representations.

It is exactly how things are done in babel-parser, so I feel like there will be some potential bugs when a CallExpression visitor does not take OptionalCallExpression into account. But in this case I fix this bug by removing the code lol.

@JLHwung JLHwung added this to the v7.8.0 milestone Dec 30, 2019
@nicolo-ribaudo nicolo-ribaudo merged commit 7bc22e4 into babel:master Jan 10, 2020
4 of 5 checks passed
4 of 5 checks passed
build (13.x)
test262 Workflow: test262
Travis CI - Pull Request Build Passed
build-standalone Workflow: build-standalone
e2e Workflow: e2e
@nicolo-ribaudo nicolo-ribaudo deleted the JLHwung:fix-numeric-separator branch Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.