New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are technically no negative numeric literals in ECMAScript. #67

Closed
cscott opened this Issue Jun 7, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@cscott

cscott commented Jun 7, 2013

The official ECMAScript grammar parses negative literals as applications of unary minus to a non-negative numeric literal. The ECMAScript grammar (see section 7.8.3 of ECMA-262 5th edition) does not allow a leading + or - sign for a numeric literal.

Currently the spidermonkey asm.js parser accepts "-5" as a numeric literal, as well as "-(5)", but rejects "+5" (and rejects "+(5)" as well).

To be rigorously correct, either you need to introduce a new AsmJSNumericLiteral production which allows the leading -, or add a note to section 4 indicating that all uses of NumericLiteral are intended to also match a leading minus, followed by an optionally-parenthesized NumericLiteral.

@jruderman

This comment has been minimized.

Show comment
Hide comment
@jruderman

jruderman Jun 12, 2013

Is (-(0xfeedbeef)) an invalid out-of-range integer literal, or is it an asm unary minus operation applied to an int (which happens to be an unsigned)?

jruderman commented Jun 12, 2013

Is (-(0xfeedbeef)) an invalid out-of-range integer literal, or is it an asm unary minus operation applied to an int (which happens to be an unsigned)?

@cscott

This comment has been minimized.

Show comment
Hide comment
@cscott

cscott Jun 24, 2013

https://bugzilla.mozilla.org/show_bug.cgi?id=886285 is related.
We need to be careful about how we define negative integer literals. Both @jruderman's example from the comment above, and his example in bug 886285 (negative zero) need to be handled carefully.

cscott commented Jun 24, 2013

https://bugzilla.mozilla.org/show_bug.cgi?id=886285 is related.
We need to be careful about how we define negative integer literals. Both @jruderman's example from the comment above, and his example in bug 886285 (negative zero) need to be handled carefully.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Aug 12, 2014

The spec handles negative numbers by explicitly handling the negative sign for NumericLiterals wherever they may occur.

ghost commented Aug 12, 2014

The spec handles negative numbers by explicitly handling the negative sign for NumericLiterals wherever they may occur.

@ghost ghost closed this Aug 12, 2014

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment