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

--HG--
extra : rebase_source : d8c67ef94022fb06870f18e605c841f3447105f2
This commit is contained in:
Jan de Mooij 2016-01-12 19:23:26 +01:00
Родитель 8c665083ad
Коммит 4c87c378bb
2 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -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; })();

Просмотреть файл

@ -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;