-
-
Notifications
You must be signed in to change notification settings - Fork 255
parseInt(08)
should work in sloppy mode?
#420
Comments
Hey @babel-bot! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
hi, I started working on this issue and I have question: what behavior will be correct? |
I think we should do what spec is saying if it is speced. Otherwise we could see what other engines are doing. Node is doing this:
So it seems if 8 or 9 are part of the number which starts with 0 it is treated as decimal either strict or non-strict. At least that is the behaviour of node 6.10. Maybe you can look in the specs and see if this is correct. |
Spec text is hard to read, but it is https://www.ecma-international.org/ecma-262/7.0/#prod-annexB-NonOctalDecimalIntegerLiteral The important part is |
V8 fixed this pretty recently (but it's fixed in Chrome stable!), so I'm not surprised that node still gets it wrong. cc @Alxpy; I think your PR accepts |
@loganfsmyth, you commented on the babel issue:
In my opinion, no. Just assume annex B is in effect. Since all browser JS engines implement it, and node implements it, there's no major environment in which it's disabled. And there probably never will be, since disabling it would Break The Web™ and new implementations usually want their syntax to match that of other implementations. Use of annex B extensions is bad style, I think, but that's an issue for linters or (in some cases) strict mode, not a parser. |
Original issue submitted by @kangax in babel/babel#4757
Input Code
Babel Configuration (.babelrc, package.json, cli command)
Expected Behavior
Should evaluate to
8
.Current Behavior
Throws SyntaxError.
Your Environment
The text was updated successfully, but these errors were encountered: