Status: New
Owner: ----
New issue 2311 by [email protected]: Inconsistent closure behaviour
in "with" statement.
http://code.google.com/p/v8/issues/detail?id=2311
Named functions within "with" statements are (incorrectly?) lifted out of
the "with" scope and therefore don't capture the scope object in their
lexical environments. Closures, otoh, capture the scope object correctly.
Not sure whether this is according to spec, but it seems inconsistent. It
is also inconsistent with Firefox's implementation in which both forms of
functions capture the scope object correctly.
Browsers: Chrome Canary 23.0.1249.0, Firefox 12.0
Test case: The following code snippet fails with "ReferenceError" in V8,
but runs as expected in Firefox.
{{{
var scope = {msg: "hello world"};
var f;
with (scope) {
function show() {
console.log(msg);
}
f = show;
}
f();
}}}
The following code works in V8, though -
{{{
var scope = {msg: "hello world"};
var f;
with (scope) {
f = function () {
console.log(msg);
};
}
f();
}}}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev