anonymous javascript function causes a syntax error / FFX >= 1.0.5 Mozilla >= 1.7.10

RESOLVED DUPLICATE of bug 301693

Status

()

Firefox
General
RESOLVED DUPLICATE of bug 301693
13 years ago
13 years ago

People

(Reporter: jens, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

13 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6

The following three lines of javscript code caused no issues in earlier releases 

new Function("", "alert(1);");
function() { alert(1); }
7;

Since FFX 1.0.5 and Mozilla 1.7.10 line number 2 causes a javascript syntax error. 
Question 1) Why? OK, it doesn't make sense because there is no context but IMHO
the syntax is correct. that's why I think Javascript Console should show a
Warning instead of a Error. 
Question 2) Why is line 1 still working?


Reproducible: Always

Comment 1

13 years ago
Why shouldn't line 1 work? Throwing away the result of an expression isn't 
forbidden.

*** This bug has been marked as a duplicate of 301693 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → DUPLICATE
(Reporter)

Comment 2

13 years ago
Yeah - completely understandable...
...but "function() { alert(1); }" could be either a FunctionDeclaration or a
FunctionExpression (ECMA 262 chapter 13) and as you just said: "Throwing away
the result of an expression isn't forbidden" ;)

You need to log in before you can comment on or make changes to this bug.