{a: 5}
This is not an object but represents a block (for some reason). It should compile and output 5. Instead Boa gives: Parsing Error: expected token ';', got ':' in expression statement.
EDIT:
Comparing with Chrome this actually should give an object. But {a: 5}; (notice semicolon at the end) should give a block with labeled statement.
a: is a Lable Stmt.
a:is a Lable Stmt.
Yes. It is, we currently can't parse Labeled statements
@HalidOdat I once wrote ecmascript's lexical analyzer, which is why I know this :)
{a: 1} should output {a: 1} because its an object literal, have you tested this in other engines?
Strange.
I'm pretty sure I tested this exact example in Chrome and it gave out the code block with label a pointing at 5. But now I'm retesting in Chrome and indeed gives an object {a: 5}. Could it be the behavior changed in the meantime in Chrome.
I managed to reproduce with {a: 5}; (note the semicolon at the end) in Chrome. I'll test again in boa these two examples (with and without the semicolon) and report.
OK. I've checked. In boa:
{a: 5} throws Parsing Error: expected token ';', got ':' in expression statement at line... instead of outputting the object as in Chrome.
{a: 5}; (notice semicolon termination) throws the same Parsing Error: expected token ';', got ':' in expression statement at line... instead of outputting 5 as in Chrome.
This is being worked on in #549.
This is fixed
Most helpful comment
@HalidOdat I once wrote ecmascript's lexical analyzer, which is why I know this :)