Bug 1146136 - Followup to condition tests using |super| syntax on class syntax being enabled. r=bustage

This commit is contained in:
Jeff Walden 2015-06-29 15:45:54 -07:00
parent 1c422f205e
commit 4666624678

View File

@ -82,9 +82,26 @@ var repair = {}, demolition = {};
Function("var a, b; [(repair.man), b] = [1, 2];")();
Function("var a, b; [(demolition['man']) = 'motel', b] = [1, 2];")();
Function("var a, b; [(demolition['man' + {}]) = 'motel', b] = [1, 2];")(); // evade constant-folding
Function("var a, b; var obj = { x() { [(super.man), b] = [1, 2]; } };")();
Function("var a, b; var obj = { x() { [(super[8]) = 'motel', b] = [1, 2]; } };")();
Function("var a, b; var obj = { x() { [(super[8 + {}]) = 'motel', b] = [1, 2]; } };")(); // evade constant-folding
function classesEnabled()
{
try
{
new Function("class B { constructor() { } }; class D extends B { constructor() { super(); } }");
return true;
}
catch (e if e instanceof SyntaxError)
{
return false;
}
}
if (classesEnabled())
{
Function("var a, b; var obj = { x() { [(super.man), b] = [1, 2]; } };")();
Function("var a, b; var obj = { x() { [(super[8]) = 'motel', b] = [1, 2]; } };")();
Function("var a, b; var obj = { x() { [(super[8 + {}]) = 'motel', b] = [1, 2]; } };")(); // evade constant-folding
}
// In strict mode, assignment to funcall *immediately* triggers ReferenceError
// before we can recognize this doesn't even match the destructuring grammar to