Bug 676343 - Lexical scoping bug involving UPVAR_LEVEL_LIMIT. r=brendan.

This commit is contained in:
Jason Orendorff 2011-09-01 11:31:09 -05:00
parent 9efdbba146
commit 0c504c31ce
4 changed files with 20 additions and 2 deletions

View File

@ -2358,7 +2358,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
*/ */
if (op != JSOP_NAME) if (op != JSOP_NAME)
return JS_TRUE; return JS_TRUE;
if (level >= UpvarCookie::UPVAR_LEVEL_LIMIT) if (skip >= UpvarCookie::UPVAR_LEVEL_LIMIT)
return JS_TRUE; return JS_TRUE;
if (cg->flags & TCF_FUN_HEAVYWEIGHT) if (cg->flags & TCF_FUN_HEAVYWEIGHT)
return JS_TRUE; return JS_TRUE;

View File

@ -1436,7 +1436,6 @@ js::GetUpvar(JSContext *cx, uintN closureLevel, UpvarCookie cookie)
{ {
JS_ASSERT(closureLevel >= cookie.level() && cookie.level() > 0); JS_ASSERT(closureLevel >= cookie.level() && cookie.level() > 0);
const uintN targetLevel = closureLevel - cookie.level(); const uintN targetLevel = closureLevel - cookie.level();
JS_ASSERT(targetLevel < UpvarCookie::UPVAR_LEVEL_LIMIT);
StackFrame *fp = FindUpvarFrame(cx, targetLevel); StackFrame *fp = FindUpvarFrame(cx, targetLevel);
uintN slot = cookie.slot(); uintN slot = cookie.slot();

View File

@ -111,6 +111,7 @@ script regress-665355.js
script regress-666599.js script regress-666599.js
script regress-667047.js script regress-667047.js
script regress-672892.js script regress-672892.js
script regress-672893.js
script regress-673070-1.js script regress-673070-1.js
script regress-673070-2.js script regress-673070-2.js
script regress-673070-3.js script regress-673070-3.js

View File

@ -0,0 +1,18 @@
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/
function f() {
return function () { return function () { return function () {
return function () { return function () { return function () {
return function () { return function () { return function () {
return function () { return function () { return function () {
return function () { return function () { return function (a) {
var v = a;
assertEq(v, 42);
return function() { return v; };
}; }; }; }; }; }; }; }; }; }; }; }; }; }; };
};
assertEq(f()()()()()()()()()()()()()()()(42)(), 42);
reportCompare(0, 0, 'ok');