The expression eval("var x = 0;") returns 0 instead of undefined. This causes the JavaScriptCore test ecma_3/Expressions/11.9.6-1.js to fail. Oliver suggested sending something other than dst to the expression in VarStatementNode::emitCode(), but that doesn't work, because then eval("f(); var x= 0;") will return the return value of f(). It seems the best way to fix this is to see if a variable statement is the last statement in a list of statements, in which case you generate code to overwrite its return value with undefined.
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.
Committed r32520