WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 15200
some 'return' statements are allowed outside the body of a function
https://bugs.webkit.org/show_bug.cgi?id=15200
Summary
some 'return' statements are allowed outside the body of a function
David Kilzer (:ddkilzer)
Reported
2007-09-12 22:43:15 PDT
* SUMMARY A 'return' statement outside of the body of a function should be syntactically incorrect. JavaScriptCore currently accepts such a construct. * STEPS TO REPRODUCE 1. Open test case in Safari/WebKit. * EXPECTED RESULTS "PASS" should appear on the page. * ACTUAL RESULTS "FAIL" appears on the page. * REGRESSION This is not a regression as Safari 2.0.4 (419.3) with original WebKit on Mac OS X 10.4.10 (8R218) behaves the same way. Tested with a local debug build of WebKit
r25505
with Safari 3 Public Beta v. 3.0.3 (522.12.1) on Mac OS X 10.4.10 (8R218).
Attachments
Test case
(124 bytes, text/html)
2007-09-12 22:44 PDT
,
David Kilzer (:ddkilzer)
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
David Kilzer (:ddkilzer)
Comment 1
2007-09-12 22:44:05 PDT
Created
attachment 16274
[details]
Test case
Geoffrey Garen
Comment 2
2007-09-12 22:47:12 PDT
Interesting. I know we disallow return statements in other cases. This must be an edge case we didn't catch before.
Cameron Zwarich (cpst)
Comment 3
2008-06-09 22:51:55 PDT
The syntax error is generated, but it is only thrown if the return statement would otherwise be executed. For compatibility reasons, this is the approach we take with all other "you are using this statement in the wrong place" syntax errors. Should we do it differently in this case?
David Kilzer (:ddkilzer)
Comment 4
2009-05-24 07:05:56 PDT
(In reply to
comment #3
)
> The syntax error is generated, but it is only thrown if the return statement > would otherwise be executed. For compatibility reasons, this is the approach we > take with all other "you are using this statement in the wrong place" syntax > errors. Should we do it differently in this case?
Firefox 3.0.10 "passes" the test and prints this to its Error Console: Error: return not in function Line 4
Gavin Barraclough
Comment 5
2011-06-14 17:23:32 PDT
This is fixed in ToT - we made all syntax error early errors (per ES5) a while back.
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