Bug 1237564 - Fix minor bug with a lexical declaration shadowing a non-configurable global. r=shu

This commit is contained in:
Jan de Mooij 2016-01-12 19:23:26 +01:00
parent 5a56ed2e29
commit 43adf056d6
2 changed files with 13 additions and 5 deletions

View File

@ -0,0 +1,8 @@
// |jit-test| error:ReferenceError: can't access lexical
try {
evaluate("let x = (() => { throw 3 })();");
} catch(e) {
assertEq(e, 3);
}
Object.defineProperty(this, "x", {});
(function() { x = 3; })();

View File

@ -2242,11 +2242,11 @@ BaselineCompiler::emit_JSOP_BINDGNAME()
frame.push(ObjectValue(*globalLexical));
return true;
}
}
// We can bind name to the global object if the property exists on the
// global and is non-configurable, as then it cannot be shadowed.
if (Shape* shape = script->global().lookup(cx, name)) {
} else if (Shape* shape = script->global().lookup(cx, name)) {
// If the property does not currently exist on the global lexical
// scope, we can bind name to the global object if the property
// exists on the global and is non-configurable, as then it cannot
// be shadowed.
if (!shape->configurable()) {
frame.push(ObjectValue(script->global()));
return true;