Bug 59795
| Summary: | Inconsistent SyntaxError from new Function(...) | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | mikesamuel <mikesamuel> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | Normal | CC: | barraclough, oliver |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | Mac | ||
| OS: | OS X 10.5 | ||
mikesamuel@gmail.com
Executing the Function constructor with a mis-parenthesized input thus
Function("(i + (j)")
exits abruptly with a SyntaxError:
SyntaxError: Parse error
Executing the same but with the return keyword before the mis-parenthesized expression does not error out:
Function("return (i + (j)")
evaluates normally with the value
function anonymous() { return (i + (j);
}
I expected the first example and the second example to both produce a SyntaxError.
I.e., if this is fixed, I expect
Function("return (i + (j)")
Note that
var i = 1
var j = 2
typeof Function("return (i + (j)")()
evaluates normally with the string
"undefined"
not "number" as might be done if bad inputs are being intentionally massaged or a SyntaxError as might be done if parsing is intentionally done lazily.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Gavin Barraclough
Looks like these have been fixed, added the extra test cases in r110398