Discussion:
Errors in incorrect number literals
Den Tuzhik
2014-10-14 21:50:45 UTC
Permalink
?
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):
https://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.

Denis.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141015/a975dd9d/attachment.html>
Caitlin Potter
2014-10-14 21:59:57 UTC
Permalink
`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).
?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).
```
0xFE
0b012
0o758
```
https://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.
Denis.
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141014/c1a81dbd/attachment.html>
Brendan Eich
2014-10-14 23:10:16 UTC
Permalink
Post by Caitlin Potter
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.

/be
Den Tuzhik
2014-10-15 08:18:56 UTC
Permalink
Right, it was a typo. Consider `0xFW`.

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

Denis.
Post by Caitlin Potter
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.
/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141015/67166449/attachment-0001.html>
Axel Rauschmayer
2014-10-15 08:36:51 UTC
Permalink
According to 11.8.3, you'll get a syntax error ? they won't even be parsed, because they are not syntactically legal.


[[[Sent from a mobile device. Please forgive brevity and typos.]]]

Dr. Axel Rauschmayer
axel at rauschma.de
http://rauschma.de
Post by Den Tuzhik
Right, it was a typo. Consider `0xFW`.
Nevertheless the question remains, what kind of error will such cases produce?
Denis.
Post by Caitlin Potter
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.
/be
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141015/ff52d79d/attachment.html>
Den Tuzhik
2014-10-15 09:05:00 UTC
Permalink
Thanks.

Denis.
Post by Axel Rauschmayer
According to 11.8.3, you'll get a syntax error ? they won't even be
parsed, because they are not syntactically legal.
[[[Sent from a mobile device. Please forgive brevity and typos.]]]
Dr. Axel Rauschmayer
axel at rauschma.de
http://rauschma.de
Right, it was a typo. Consider `0xFW`.
Nevertheless the question remains, what kind of error will such cases produce?
Denis.
Post by Caitlin Potter
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.
/be
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141015/51b7bddb/attachment.html>
Loading...