WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 13790
14090
Redeclaring function throws syntax error
https://bugs.webkit.org/show_bug.cgi?id=14090
Summary
Redeclaring function throws syntax error
Brad Fults
Reported
2007-06-12 09:18:04 PDT
Using
http://mochikit.com/examples/interpreter/
as a simple CLI. In
r22084
nightly:
>>> for (var i=10;i>=0;i--) function x(k) { return ++k; };
Error: line 1 message Parse error name SyntaxError In Firefox 2.0.0.4:
>>> for (var i=10;i>=0;i--) function x(k) { return ++k; };
[no error] In Opera 9.21:
>>> for (var i=10;i>=0;i--) function x(k) { return ++k; };
[no error] Similar results can be found in IE.
Attachments
Add attachment
proposed patch, testcase, etc.
Mark Rowe (bdash)
Comment 1
2007-06-13 16:21:30 PDT
This appears to be due to the lack of {}'s inside the for statement. The following example throws a syntax error: for (var i = 10; i >= 0; i--) function x(k) { return ++k; }; The following example does not: for (var i = 10; i >= 0; i--) { function x(k) { return ++k; }; }
Cameron Zwarich (cpst)
Comment 2
2008-06-09 16:39:22 PDT
This is invalid syntax, according to the grammar in the ECMA spec. The body of a for loop is a Statement, and a FunctionDeclaration is not a Statement. Unless this is actually a compatibility issue, we should probably close this bug.
Alexey Proskuryakov
Comment 3
2008-06-09 16:57:54 PDT
Per the bug description, this sounds like a compatibility issue.
Cameron Zwarich (cpst)
Comment 4
2008-11-24 16:16:08 PST
*** This bug has been marked as a duplicate of
13790
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug