tc39 / proposal-number-fromstring

{BigInt,Number}.fromString(string, radix)
https://mathiasbynens.github.io/proposal-number-fromstring/
65 stars 7 forks source link

Consider not accepting trailing junk #5

Closed domenic closed 6 years ago

domenic commented 6 years ago

This proposal seems to have as its goals tightening up some of the looseness of parseInt, but it then starts allowing trailing junk characters. The reasoning behind this choice is not clear. And it seems to depart from the intuition that this is supposed to be an inverse of toString, which never produces trailing junk.

I'd suggest a SyntaxError for those cases too.

littledan commented 6 years ago

Seconded; I was surprised by this in the explainer (which just has "0x1" examples) and even more surprised by the spec text. I was expecting these to be SyntaxErrors.

mathiasbynens commented 6 years ago

a29f339980abb55d93f50c650294eedf071363d5 includes this change. Please take a look and let me know of any issues.