Bug 1255167 - Default destructuring arguments should show up as lexical dependencies; r=jorendorff

--HG--
extra : rebase_source : 88d9870638eb5565410a5acc23c19f119e56a117
This commit is contained in:
Morgan Phillips 2016-06-07 14:12:19 -07:00
Родитель a2e846edaf
Коммит 25742678cc
2 изменённых файлов: 14 добавлений и 0 удалений

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

@ -9352,7 +9352,12 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
return null();
tokenStream.consumeKnownToken(TOK_ASSIGN);
bool saved = pc->inDeclDestructuring;
// Setting `inDeclDestructuring` to false allows name use to be noted
// in `identifierName` See Bug: 1255167.
pc->inDeclDestructuring = false;
Node rhs = assignExpr(InAllowed, yieldHandling, TripledotProhibited);
pc->inDeclDestructuring = saved;
if (!rhs)
return null();

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

@ -123,5 +123,14 @@ assertEq((({a = 0} = {}) => a)({a: 1}), 1);
assertEq(j, 2);
}
// Default destructuring values, which are variables, should be defined
// within closures (Bug 1255167).
{
let f = function(a){
return (function({aa = a}){ return aa; })({});
};
assertEq(f(9999), 9999);
}
if (typeof reportCompare == "function")
reportCompare(true, true);