|Summary:||SQUIRRELFISH: eval returns the wrong value for a variable declaration statement|
|Product:||WebKit||Reporter:||Cameron Zwarich (cpst) <zwarich>|
|Severity:||Normal||CC:||ggaren, mjs, oliver|
|Version:||528+ (Nightly build)|
|Bug Depends on:|
Description Cameron Zwarich (cpst) 2008-04-24 12:41:04 PDT
Comment 1 Cameron Zwarich (cpst) 2008-04-24 12:49:28 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.
Comment 2 Oliver Hunt 2008-04-24 13:56:57 PDT
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().
Comment 3 Cameron Zwarich (cpst) 2008-04-24 15:29:50 PDT
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 4 Darin Adler 2008-04-24 15:37:03 PDT
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.
Comment 5 Cameron Zwarich (cpst) 2008-04-24 15:43:03 PDT
Created attachment 20803 [details] Revised proposed patch Here is a revised version of the patch that avoids the use of UNUSED_PARAM.