Summary: | SQUIRRELFISH: eval returns the wrong value for a variable declaration statement | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Cameron Zwarich (cpst) <zwarich> | ||||||
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | ggaren, mjs, oliver | ||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | All | ||||||||
OS: | All | ||||||||
Bug Depends on: | |||||||||
Bug Blocks: | 18624 | ||||||||
Attachments: |
|
Description
Cameron Zwarich (cpst)
2008-04-24 12:41:04 PDT
I should also add that there is nothing in the ECMA spec that suggests it should return undefined, at least as far as I can tell. eval("var x = 0") should return undefined as nothing should ever assign to dst. However the rule is (afaict from my testing) that var statements are transparent to the result value, so eval("someExpr; var x = 0;") will return the result of someExpr, assuming someExpr actually has a return value. I believe therefore the example eval("f(); var x=0;") *should* return the result of f(). Created attachment 20802 [details]
Proposed patch
Yeah, Oliver, I accidentally misread the spec. Here is a patch that fixes the problem. It seems to be a 0.2% progression on SunSpider. It fixes ecma_3/Expressions/11.9.6-1.js, but causes js1_5/GetSet/getset-005.js to crash, like many other tests using getters and setters.
Comment on attachment 20802 [details]
Proposed patch
It's better to omit or comment out the argument name "dst" rather than doing "UNUSED_PARAM(dst)" when practical. There are times when due to #ifdef's or ASSERT, for example, that UNUSED_PARAM is unavoidable or better. But I don't think this is one of those times.
Created attachment 20803 [details]
Revised proposed patch
Here is a revised version of the patch that avoids the use of UNUSED_PARAM.
|