Errors in incorrect number literals

# Den Tuzhik (11 years ago)

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:

0xFE
0b012
0o758

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.

# Caitlin Potter (11 years ago)

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).

# Brendan Eich (11 years ago)

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.

# Den Tuzhik (11 years ago)

Right, it was a typo. Consider 0xFW.

Nevertheless the question remains, what kind of error will such cases produce?

# Axel Rauschmayer (11 years ago)

According to 11.8.3, you'll get a syntax error – they won't even be parsed, because they are not syntactically legal.

# Den Tuzhik (11 years ago)

Thanks.