Errors in incorrect number literals
0b012
looks like a syntax error to me (it doesn’t match the binary literal grammar), same with 0o758
.
I’m not sure what the problem with 0xFE
is supposed to be, though? But I would expect these to be caught during the first run of parsing, because they simply violate the grammar of the language (with the exception of the hex example).
Caitlin Potter wrote:
I’m not sure what the problem with
0xFE
is supposed to be, though?
Right, 0xFE is a fine hex literal. One must remember all the punning uses of hex: 0xFEEDFACE, 0xFEEDBABE, 0xCAFE, etc.
Right, it was a typo. Consider 0xFW
.
Nevertheless the question remains, what kind of error will such cases produce?
According to 11.8.3, you'll get a syntax error – they won't even be parsed, because they are not syntactically legal.
Thanks.
While current spec describes new binary, octal and hex literals, it doesn't says anything about edge cases errors (at least I couldn't find anything).
Consider:
I would expect these to be type errors, but none of current errors descriptions include NumericLiterals (which is 11.8.3 in spec): people.mozilla.org/~jorendorff/es6-draft.html#sec-native-error-types-used-in-this-standard-rangeerror (and below).
I may have overlooked it of course, would be great if someone could point me to the place, where it's described.