Closed
Bug 120157
Opened 24 years ago
Closed 24 years ago
{}.a is an error, print({}.a) is not
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: timeless, Assigned: khanson)
Details
current-cvsbuild\mozilla\dist\WIN32_D.OBJ\bin>xpcshell.exe -s -w
js> a={};a.b
typein:1: strict warning: assignment to undeclared variable a
typein:1: strict warning: reference to undefined property a.b
js> {}.a
typein:2: syntax error:
typein:2: {}.a
typein:2: ..^
typein:2: SyntaxError: syntax error:
typein:2: {}.a
typein:2: ..^
js> print({}.a)
typein:3: strict warning: reference to undefined property {}.a
undefined
Comment 1•24 years ago
|
||
Same thing in my SpiderMonkey shell. Isn' it odd we get TWO syntax errors:
[//d/JS_TRUNK/mozilla/js/src/WINNT4.0_DBG.OBJ] ./js -s -w
js> {}.a
4: syntax error:
4: {}.a
4: ..^
4: SyntaxError: syntax error:
4: {}.a
4: ..^
Whereas these all just give strict warnings:
js> print({}.a);
5: strict warning: reference to undefined property {}.a
undefined
js> if ({}.a) {print('OK')}
6: strict warning: reference to undefined property {}.a
js> var x = {}.a;
7: strict warning: reference to undefined property {}.a
Note this:
js> typeof {}.a
undefined
js> {}.a == undefined
25: syntax error:
25: {}.a == undefined
25: ..^
25: SyntaxError: syntax error:
25: {}.a == undefined
25: ..^
Comment 2•24 years ago
|
||
Reassigning to Kenton; cc'ing Brendan in case this is of interest -
Assignee: rogerl → khanson
oh yeah of course the reason i was playing with this at all was typeof :-).
Odd that i didn't notice the significance of the second syntax error (note:
'syntax error:' and 'SyntaxError: syntax error:'
my guess about that is that the first one shouldn't be emitted and should be
subsumed (?) by the second one.
otoh, perhaps this is expected behavior
>\build\mozilla\dist\WIN32_D.OBJ\bin\xpcshell.exe
js> /1
typein:1: unterminated regular expression literal:
typein:1: /1
typein:1: ^
typein:1: SyntaxError: unterminated regular expression literal:
typein:1: /1
typein:1: ^
odd, i wasn't trying to create a regular expression, i was trying to not take
something and divide by 1. well, compiler knows best :)
Comment 4•24 years ago
|
||
This bug is invalid, and timeless should know better. Unless you put {} in an
expression context (such as print's actual parameter, or in parens), it's a
block statement, not an object literal.
/be
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → INVALID
i'll go hide under a rock now. a new bug should be filed for syntax error
outputting twice if that's a bug at all.
Status: RESOLVED → VERIFIED
Comment 6•24 years ago
|
||
timeless: that double-report is a bug, due to a mess left behind when errors as
exceptions went in. I have a patch. Please file the bug on me, cc'ing khanson,
shaver, jband, and rogerl. Thanks,
/be
Comment 7•24 years ago
|
||
I have filed bug 120197 on the double-report issue.
You need to log in
before you can comment on or make changes to this bug.
Description
•