Bug 1023609 - Remove SpiderMonkey support for nonstandard let expressions. r=shu

This commit is contained in:
Chris Peterson 2015-05-19 23:20:45 -07:00
parent 995bebec24
commit 8c758c169d
106 changed files with 112 additions and 1746 deletions

View File

@ -4858,41 +4858,15 @@ BytecodeEmitter::emitIf(ParseNode* pn)
}
/*
* pnLet represents one of:
* pnLet represents a let-statement: let (x = y) { ... }
*
* let-expression: (let (x = y) EXPR)
* let-statement: let (x = y) { ... }
*
* For a let-expression 'let (x = a, [y,z] = b) e', EmitLet produces:
*
* bytecode stackDepth srcnotes
* evaluate a +1
* evaluate b +1
* dup +1
* destructure y
* pick 1
* dup +1
* destructure z
* pick 1
* pop -1
* setlocal 2 -1
* setlocal 1 -1
* setlocal 0 -1
* pushblockscope (if needed)
* evaluate e +1
* debugleaveblock
* popblockscope (if needed)
*
* Note that, since pushblockscope simply changes fp->scopeChain and does not
* otherwise touch the stack, evaluation of the let-var initializers must leave
* the initial value in the let-var's future slot.
*/
/*
* Using MOZ_NEVER_INLINE in here is a workaround for llvm.org/pr14047. See
* the comment on emitSwitch.
*/
MOZ_NEVER_INLINE bool
BytecodeEmitter::emitLet(ParseNode* pnLet)
BytecodeEmitter::emitLetBlock(ParseNode* pnLet)
{
MOZ_ASSERT(pnLet->isArity(PN_BINARY));
ParseNode* varList = pnLet->pn_left;
@ -6722,9 +6696,8 @@ BytecodeEmitter::emitConditionalExpression(ConditionalExpression& conditional)
* ignore the value pushed by the first branch. Execution will follow
* only one path, so we must decrement this->stackDepth.
*
* Failing to do this will foil code, such as let expression and block
* code generation, which must use the stack depth to compute local
* stack indexes correctly.
* Failing to do this will foil code, such as let block code generation,
* which must use the stack depth to compute local stack indexes correctly.
*/
MOZ_ASSERT(stackDepth > 0);
stackDepth--;
@ -7542,8 +7515,7 @@ BytecodeEmitter::emitTree(ParseNode* pn)
break;
case PNK_LETBLOCK:
case PNK_LETEXPR:
ok = emitLet(pn);
ok = emitLetBlock(pn);
break;
case PNK_CONST:

View File

@ -490,7 +490,7 @@ struct BytecodeEmitter
bool emitWith(ParseNode* pn);
MOZ_NEVER_INLINE bool emitLabeledStatement(const LabeledStatement* pn);
MOZ_NEVER_INLINE bool emitLet(ParseNode* pnLet);
MOZ_NEVER_INLINE bool emitLetBlock(ParseNode* pnLet);
MOZ_NEVER_INLINE bool emitLexicalScope(ParseNode* pn);
MOZ_NEVER_INLINE bool emitSwitch(ParseNode* pn);
MOZ_NEVER_INLINE bool emitTry(ParseNode* pn);

View File

@ -402,7 +402,6 @@ ContainsHoistedDeclaration(ExclusiveContext* cx, ParseNode* node, bool* result)
case PNK_FALSE:
case PNK_NULL:
case PNK_THIS:
case PNK_LETEXPR:
case PNK_ELISION:
case PNK_NUMBER:
case PNK_NEW:

View File

@ -591,14 +591,6 @@ class FullParseHandler
block->pn_expr = body;
}
ParseNode* newLetExpression(ParseNode* vars, ParseNode* block, const TokenPos& pos) {
ParseNode* letExpr = newBinary(PNK_LETEXPR, vars, block);
if (!letExpr)
return nullptr;
letExpr->pn_pos = pos;
return letExpr;
}
ParseNode* newLetBlock(ParseNode* vars, ParseNode* block, const TokenPos& pos) {
ParseNode* letBlock = newBinary(PNK_LETBLOCK, vars, block);
if (!letBlock)

View File

@ -424,7 +424,6 @@ class NameResolver
case PNK_DIVASSIGN:
case PNK_MODASSIGN:
case PNK_ELEM:
case PNK_LETEXPR:
case PNK_COLON:
case PNK_CASE:
case PNK_SHORTHAND:

View File

@ -266,7 +266,6 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
case PNK_MODASSIGN:
// ...and a few others.
case PNK_ELEM:
case PNK_LETEXPR:
case PNK_IMPORT_SPEC:
case PNK_EXPORT_SPEC:
case PNK_COLON:

View File

@ -133,7 +133,6 @@ class UpvarCookie
F(LEXICALSCOPE) \
F(LET) \
F(LETBLOCK) \
F(LETEXPR) \
F(IMPORT) \
F(IMPORT_SPEC_LIST) \
F(IMPORT_SPEC) \

View File

@ -2989,8 +2989,8 @@ Parser<ParseHandler>::reportRedeclaration(Node pn, Definition::Kind redeclKind,
}
/*
* Define a lexical binding in a block, let-expression, or comprehension scope. pc
* must already be in such a scope.
* Define a lexical binding in a block, or comprehension scope. pc must
* already be in such a scope.
*
* Throw a SyntaxError if 'atom' is an invalid name. Otherwise create a
* property for the new variable on the block object, pc->staticScope;
@ -3680,14 +3680,13 @@ Parser<SyntaxParseHandler>::pushLetScope(HandleStaticBlockObject blockObj, StmtI
}
/*
* Parse a let block statement or let expression (determined by 'letContext').
* Parse a let block statement.
* In both cases, bindings are not hoisted to the top of the enclosing block
* and thus must be carefully injected between variables() and the let body.
*/
template <typename ParseHandler>
typename ParseHandler::Node
Parser<ParseHandler>::deprecatedLetBlockOrExpression(YieldHandling yieldHandling,
LetContext letContext)
Parser<ParseHandler>::deprecatedLetBlock(YieldHandling yieldHandling)
{
MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_LET));
@ -3710,82 +3709,22 @@ Parser<ParseHandler>::deprecatedLetBlockOrExpression(YieldHandling yieldHandling
if (!block)
return null();
bool needExprStmt = false;
if (letContext == LetStatement) {
bool matched;
if (!tokenStream.matchToken(&matched, TOK_LC, TokenStream::Operand))
return null();
if (!matched) {
/*
* Strict mode eliminates a grammar ambiguity with unparenthesized
* LetExpressions in an ExpressionStatement. If followed immediately
* by an arguments list, it's ambiguous whether the let expression
* is the callee or the call is inside the let expression body.
*
* function id(x) { return x; }
* var x = "outer";
* // Does this parse as
* // (let (loc = "inner") id)(loc) // "outer"
* // or as
* // let (loc = "inner") (id(loc)) // "inner"
* let (loc = "inner") id(loc);
*
* See bug 569464.
*/
if (!reportWithOffset(ParseStrictError, pc->sc->strict(), begin,
JSMSG_STRICT_CODE_LET_EXPR_STMT))
{
return null();
}
MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_LET);
/*
* If this is really an expression in let statement guise, then we
* need to wrap the PNK_LETEXPR node in a PNK_SEMI node so that we
* pop the return value of the expression.
*/
needExprStmt = true;
letContext = LetExpression;
}
}
Node expr = statements(yieldHandling);
if (!expr)
return null();
MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_AFTER_LET);
Node expr;
if (letContext == LetStatement) {
expr = statements(yieldHandling);
if (!expr)
return null();
MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_AFTER_LET);
addTelemetry(JSCompartment::DeprecatedLetBlock);
if (!report(ParseWarning, pc->sc->strict(), expr, JSMSG_DEPRECATED_LET_BLOCK))
return null();
addTelemetry(JSCompartment::DeprecatedLetBlock);
if (!report(ParseWarning, pc->sc->strict(), expr, JSMSG_DEPRECATED_LET_BLOCK))
return null();
} else {
MOZ_ASSERT(letContext == LetExpression);
expr = assignExpr(InAllowed, yieldHandling);
if (!expr)
return null();
addTelemetry(JSCompartment::DeprecatedLetExpression);
if (!report(ParseWarning, pc->sc->strict(), expr, JSMSG_DEPRECATED_LET_EXPRESSION))
return null();
}
handler.setLexicalScopeBody(block, expr);
PopStatementPC(tokenStream, pc);
TokenPos letPos(begin, pos().end);
if (letContext == LetExpression) {
if (needExprStmt) {
if (!MatchOrInsertSemicolon(tokenStream))
return null();
}
Node letExpr = handler.newLetExpression(vars, block, letPos);
if (!letExpr)
return null();
return needExprStmt ? handler.newExprStatement(letExpr, pos().end) : letExpr;
}
return handler.newLetBlock(vars, block, letPos);
}
@ -4242,24 +4181,17 @@ Parser<FullParseHandler>::letDeclarationOrBlock(YieldHandling yieldHandling)
{
handler.disableSyntaxParser();
/* Check for a let statement or let expression. */
/* Check for a let statement. */
TokenKind tt;
if (!tokenStream.peekToken(&tt))
return null();
if (tt == TOK_LP) {
ParseNode* node =
deprecatedLetBlockOrExpression(yieldHandling, LetStatement);
ParseNode* node = deprecatedLetBlock(yieldHandling);
if (!node)
return nullptr;
if (node->isKind(PNK_LETBLOCK)) {
MOZ_ASSERT(node->isArity(PN_BINARY));
} else {
MOZ_ASSERT(node->isKind(PNK_SEMI));
MOZ_ASSERT(node->pn_kid->isKind(PNK_LETEXPR));
MOZ_ASSERT(node->pn_kid->isArity(PN_BINARY));
}
MOZ_ASSERT(node->isKind(PNK_LETBLOCK));
MOZ_ASSERT(node->isArity(PN_BINARY));
return node;
}
@ -4750,8 +4682,7 @@ Parser<FullParseHandler>::forStatement(YieldHandling yieldHandling)
MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_AFTER_FOR);
/*
* True if we have 'for (var/let/const ...)', except in the oddball case
* where 'let' begins a let-expression in 'for (let (...) ...)'.
* True if we have 'for (var/let/const ...)'.
*/
bool isForDecl = false;
@ -4790,19 +4721,13 @@ Parser<FullParseHandler>::forStatement(YieldHandling yieldHandling)
handler.disableSyntaxParser();
bool constDecl = tt == TOK_CONST;
tokenStream.consumeKnownToken(tt);
if (!tokenStream.peekToken(&tt))
isForDecl = true;
blockObj = StaticBlockObject::create(context);
if (!blockObj)
return null();
if (tt == TOK_LP) {
pn1 = deprecatedLetBlockOrExpression(yieldHandling, LetExpression);
} else {
isForDecl = true;
blockObj = StaticBlockObject::create(context);
if (!blockObj)
return null();
pn1 = variables(yieldHandling,
constDecl ? PNK_CONST : PNK_LET, nullptr, blockObj,
DontHoistVars);
}
pn1 = variables(yieldHandling,
constDecl ? PNK_CONST : PNK_LET, nullptr, blockObj,
DontHoistVars);
} else {
pn1 = expr(InProhibited, yieldHandling);
}
@ -7053,9 +6978,7 @@ LegacyCompExprTransplanter::transplant(ParseNode* pn)
// The one remaining thing to patch up is the block scope depth. We need to
// compute the maximum block scope depth of a function, so we know how much
// space to reserve in the fixed part of a stack frame. Normally this is done
// whenever we leave a statement, via AccumulateBlockScopeDepth. However if the
// head has a let expression, we need to re-assign that depth to the tail of the
// comprehension.
// whenever we leave a statement, via AccumulateBlockScopeDepth.
//
// Thing is, we don't actually know what that depth is, because the only
// information we keep is the maximum nested depth within a statement, so we
@ -7128,10 +7051,9 @@ Parser<FullParseHandler>::legacyComprehensionTail(ParseNode* bodyExpr, unsigned
* the comprehension's block scope. We allocate that id or one above it
* here, by calling PushLexicalScope.
*
* In the case of a comprehension expression that has nested blocks
* (e.g., let expressions), we will allocate a higher blockid but then
* slide all blocks "to the right" to make room for the comprehension's
* block scope.
* In the case of a comprehension expression that has nested blocks,
* we will allocate a higher blockid but then slide all blocks "to the
* right" to make room for the comprehension's block scope.
*/
adjust = pc->blockid();
pn = pushLexicalScope(&stmtInfo);
@ -8219,9 +8141,10 @@ Parser<ParseHandler>::arrayInitializer(YieldHandling yieldHandling)
*
* [i * j for (i in o) for (j in p) if (i != j)]
*
* translates to roughly the following let expression:
* translates to roughly the following code:
*
* let (array = new Array, i, j) {
* {
* let array = new Array, i, j;
* for (i in o) let {
* for (j in p)
* if (i != j)
@ -8651,9 +8574,6 @@ Parser<ParseHandler>::primaryExpr(YieldHandling yieldHandling, TokenKind tt,
case TOK_LC:
return propertyList(yieldHandling, ObjectLiteral);
case TOK_LET:
return deprecatedLetBlockOrExpression(yieldHandling, LetExpression);
case TOK_LP: {
TokenKind next;
if (!tokenStream.peekToken(&next, TokenStream::Operand))

View File

@ -326,7 +326,6 @@ struct BindData;
class CompExprTransplanter;
enum LetContext { LetExpression, LetStatement };
enum VarContext { HoistVars, DontHoistVars };
enum PropListType { ObjectLiteral, ClassBody };
@ -629,7 +628,7 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
Node generatorComprehension(uint32_t begin);
bool argumentList(YieldHandling yieldHandling, Node listNode, bool* isSpread);
Node deprecatedLetBlockOrExpression(YieldHandling yieldHandling, LetContext letContext);
Node deprecatedLetBlock(YieldHandling yieldHandling);
Node destructuringExpr(YieldHandling yieldHandling, BindData<ParseHandler>* data,
TokenKind tt);
Node destructuringExprWithoutYield(YieldHandling yieldHandling, BindData<ParseHandler>* data,

View File

@ -258,10 +258,6 @@ class SyntaxParseHandler
Node newLexicalScope(ObjectBox* blockbox) { return NodeGeneric; }
void setLexicalScopeBody(Node block, Node body) {}
Node newLetExpression(Node vars, Node block, const TokenPos& pos) {
return NodeGeneric;
}
Node newLetBlock(Node vars, Node block, const TokenPos& pos) {
return NodeGeneric;
}

View File

@ -1,9 +0,0 @@
// Binary: cache/js-dbg-64-0ba03471b3b0-linux
// Flags:
//
uneval(new Function("\
for(\
((let (functional) x) for each ([] in [])); \
yield x; \
(let (x = true) x));\
"))

View File

@ -1,15 +0,0 @@
// |jit-test| error:ReferenceError
// Binary: cache/js-dbg-32-525d852c622d-linux
// Flags: -j
//
(function() {
let(x)
(function() {
for (let a in [0, x, 0, 0])
(function() {
for (let y in [0, 0]) print
})();
})()
with({}) throw x;
})()

View File

@ -1,18 +0,0 @@
// Binary: cache/js-dbg-32-15c46082297d-linux
// Flags: -j
//
(function() {
(eval("\
(function() {\
let(e)((function() { ((function f(a) {\
if (a < 1) {\
return 1\
}\
x = arguments;\
return f(a - 1) + f(a - 2)\
})(6))\
})())\
})\
"))()
})()
gc()

View File

@ -1,9 +0,0 @@
// Binary: cache/js-dbg-64-7f7dfb33a33e-linux
// Flags:
//
x = Proxy.create((function () {}), (evalcx('')))
try {
(function () {
((let(e = eval) e).call(x, ("\"\"")))
})()
} catch (e) {}

View File

@ -1,6 +0,0 @@
// |jit-test| error:ReferenceError
// Binary: cache/js-dbg-64-242947d76f73-linux
// Flags:
//
for (b in [evalcx("let(e)eval()", evalcx('split'))]) {}

View File

@ -1,14 +0,0 @@
// |jit-test| slow;
// Binary: cache/js-dbg-32-f98c57415d8d-linux
// Flags:
//
try {
var str = '0123456789';
for (var icount = 0; icount < 25; ++icount, let(icount2, printStatus) (function() gczeal(2))[1]++)
str = str + str;
} catch(ex) {
new Date( str, false, (new RegExp('[0-9]{3}')).test('23 2 34 78 9 09'));
}
this.toSource();

View File

@ -59,9 +59,6 @@ function InLeapYear( t ) {\
function DayWithinYear( t ) {\
return( Day(t) - DayFromYear(YearFromTime(t)));\
");
lfcode.push("this.__proto__ = []; \
let ( _ = this ) Boolean (\"({ set x([, b, c]) { } })\");\
");
while (true) {
var file = lfcode.shift(); if (file == undefined) { break; }
if (file == "evaluate") {

View File

@ -1,8 +0,0 @@
// |jit-test| error:TypeError
// Binary: cache/js-dbg-32-3fa30b0edd15-linux
// Flags:
//
let ([] = 1) 3;
let (i) new [i][print[i]];

View File

@ -1,8 +0,0 @@
// |jit-test| error:Error
// Binary: cache/js-dbg-64-85e31a4bdd41-linux
// Flags:
//
function f(x = let([] = c) 1, ... __call__) {}
assertEq(this > f, true);

View File

@ -1,10 +0,0 @@
// Binary: cache/js-dbg-32-5cca0408a73f-linux
// Flags:
//
options("strict_mode");
function test(str, arg, result) {
var fun = new Function('x', str);
var got = fun.toSource();
}
test('return let (y) x;');

View File

@ -1,6 +0,0 @@
function f() {
let(x) yield x;
}
var g = f();
g.next();
g.close();

View File

@ -1,16 +0,0 @@
function TestCase(n, d, e, a)
this.passed = getTestCaseResult(e, a);
function getTestCaseResult(expected, actual) {
if (actual != actual)
return gTestcases;
}
gczeal(4);
try {
var TEST_STRING = new String("");
new TestCase(null, 0,eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") );
new TestCase(null, null, 0, eval("x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)"));
new TestCase(null, null, 0, eval("x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)"));
new TestCase(null, null, 0, eval("x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)"));
new TestCase(null, null, Number.NaN, eval("x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)"));
new new let (r) (function () {}) ();
} catch(e) {}

View File

@ -1,14 +0,0 @@
// Don't crash or assert.
(function () {
var x;
(eval("\
(function () {\
for (y in [0, 0]) let(a)((function () {\
for (w in [0, 0])\
x = 0\
})());\
with({}) {}\
})\
"))()
})()

View File

@ -1,2 +0,0 @@
// |jit-test| error: SyntaxError;
let(y = let(d = []) u, x

View File

@ -1,2 +0,0 @@
// |jit-test| error: SyntaxError;
for (let d in [(0)]) let(b = (let(e) {}), d

View File

@ -1,7 +0,0 @@
var x = 5;
let (x = x)
assertEq(x, 5);
let (x = eval("x"))
assertEq(x, 5);
let (x = function () { with ({}) return x; })
assertEq(x(), 5);

View File

@ -1,4 +0,0 @@
var x = 5;
(let (x = x) assertEq(x, 5));
(let (x = eval("x")) assertEq(x, 5));
(let (x = function () { with ({}) return x; }) assertEq(x(), 5));

View File

@ -1,6 +0,0 @@
function test(s) {
eval(s);
let (a = ({}).q = 0, x = x)
assertEq(x, 5);
}
test('var x = 5;');

View File

@ -1,15 +0,0 @@
try { let(x = Date(7), y = let(a = x)("")) {} } catch (e) {}
try {
with({
y: Float64Array
})
for each(let y in [y]) {}
} catch (e) {}
try { test(); } catch (e) {}
function test() {
try {
var result, arguments = 'adddb', arguments;
} catch (ex) {}
}

View File

@ -1 +0,0 @@
let (parsesSuccessfully = SyntaxError) function () parsesSuccessfully

View File

@ -1,4 +0,0 @@
gczeal(4);
test();
function test()
eval("with({}) let(x=[])(function(){x})()");

View File

@ -1,20 +0,0 @@
function f() {
try {} catch (e) {}
}
function g(code) {
function m() {
return "(function(){return " + code + "})()"
}
var codeNestedDeep = m(codeNestedDeep)
h(m(code), "same-compartment")
h(codeNestedDeep, "same-compartment")
}
function h(code, globalType) {
try {
evalcx(code, newGlobal(globalType))
} catch (e) {
"" + f()
}
}
function p()(function() function() {})
g("print(let(x=verifyprebarriers(),q)((x(\"\",l('')))?(\"\"):(\"\")))()")

View File

@ -1,26 +0,0 @@
var summary = '';
function printStatus (msg) {
var lines = msg.split ("\n");
}
evaluate("\
function f() {\
var ss = [\
new f(Int8Array, propertyIsEnumerable, '[let (x = 3, y = 4) x].map(0)')\
];\
}\
try {\
f();\
} catch (e) {}\
gczeal(4);\
printStatus (summary);\
");
evaluate("\
function g(n, h) {\
var a = f;\
if (n <= 0) \
return f; \
var t = g(n - 1, h);\
var r = function(x) { };\
}\
g(80, f);\
");

View File

@ -92,7 +92,7 @@ function testThrow(pattern, input) {
}
testAll(testThrow);
// XXX: Support for let blocks and expressions will be removed in bug 1023609.
// XXX: Support for let blocks will be removed in bug 1023609.
// However, they test a special code path in destructuring assignment so having
// these tests here for now seems like a good idea.
function testLetBlock(pattern, input) {
@ -103,13 +103,6 @@ function testLetBlock(pattern, input) {
}
testAll(testLetBlock);
function testLetExpression(pattern, input) {
return new Function('input',
'return (let (' + pattern + ' = input) [a, b, c, d, e, f]);'
)(input);
}
testAll(testLetExpression);
// test global const
const [ca = 1, cb = 2] = [];
assertEq(ca, 1);

View File

@ -128,7 +128,7 @@ function testThrow(pattern, input, binding) {
}
testDeclaration(testThrow);
// XXX: Support for let blocks and expressions will be removed in bug 1023609.
// XXX: Support for let blocks will be removed in bug 1023609.
// However, they test a special code path in destructuring assignment so having
// these tests here for now seems like a good idea.
function testLetBlock(pattern, input, binding) {
@ -139,12 +139,3 @@ function testLetBlock(pattern, input, binding) {
)(input);
}
testDeclaration(testLetBlock);
function testLetExpression(pattern, input, binding) {
binding = binding || 'rest';
return new Function('input',
'return (let (' + pattern + ' = input) ' + binding + ');'
)(input);
}
testDeclaration(testLetExpression);

View File

@ -8,8 +8,6 @@ assertEq(f.toString(), "function anonymous(a, ...rest) {\nreturn rest[42] + b;\n
assertEq(f.toSource(), "(function anonymous(a, ...rest) {\nreturn rest[42] + b;\n})")
assertEq(decompileFunction(f), f.toString());
assertEq(decompileBody(f), "return rest[42] + b;");
f = Function("x", "return let (y) x;");
assertEq(f.toSource(), "(function anonymous(x) {\nreturn let (y) x;\n})");
f = Function("");
assertEq(f.toString(), "function anonymous() {\n\n}");
f = Function("", "(abc)");

View File

@ -1,15 +0,0 @@
// |jit-test| error: InternalError
version(0);
eval("\
function TimeFromYear( y ) {}\
addTestCase( -2208988800000 );\
function addTestCase( t ) {\
var start = TimeFromYear((addTestCase(addTestCase << t, 0)));\
new TestCase( \
SECTION,\
'(new Date('+d+')).getUTCDay()',\
WeekDay((d)),\
(new Date(let ({ stop } = 'properties.length' )('/ab[c\\\n]/'))).getUTCDay() \
);\
}\
");

View File

@ -977,7 +977,6 @@ test("let ( x = 1, y = 2 ) { @");
test("let ( x = 1, y = 2 ) { x @");
test("let ( x = 1, y = 2 ) { x; @");
test("let ( x = 1, y = 2 ) { x; } @");
test_no_strict("let ( x = 1, y = 2 ) x @");
// Expression closures
@ -1014,22 +1013,6 @@ test("for each (let x in @");
test("for each (let x in y @");
test("for each (let x in y) @");
// let expression
test("(let @");
test("(let ( @");
test("(let ( x @");
test("(let ( x = @");
test("(let ( x = 1 @");
test("(let ( x = 1, @");
test("(let ( x = 1, y @");
test("(let ( x = 1, y = @");
test("(let ( x = 1, y = 2 @");
test("(let ( x = 1, y = 2 ) @");
test("(let ( x = 1, y = 2 ) x @");
test("(let ( x = 1, y = 2 ) x) @");
test("(let ( x = 1, y = 2 ) x); @");
// Legacy array comprehensions
test("[x @");

View File

@ -1,13 +0,0 @@
expected = "TypeError: a is not a function";
actual = "";
try {
a = ""
for each(x in [0, 0, 0, 0]) {
a %= x
} ( let (a=-a) a)()
} catch (e) {
actual = '' + e;
}
assertEq(actual, expected);

View File

@ -1,4 +0,0 @@
// |jit-test| error: TypeError
var obj = {};
let ([] = print) 3;
let ( i = "a" ) new i [ obj[i] ];

View File

@ -1,9 +0,0 @@
test();
function test() {
var f;
f = function() { (let(x) {y: z}) }
let (f = function() {
for (var t=0;t<6;++t) ++f;
}) { f(); } // { }
actual = f + '';
}

View File

@ -1,11 +0,0 @@
// |jit-test| error:InternalError
Function("\
for each(l in[(let(c)([])\
for each(l in[]))(let(c)w for(u in[]))(let(u)w for(l in[]))(let(c)w for(u in[]))\
(let(u)w for each(l in[]))(let(c)w for(u in[]))(let(u)w for(l in[]))(let(c)w for(u in[]))\
(let(u)w for each(l in[]))(let(c)w for(u in[]))(let(u)w for(l in[]))(let(c)w for(u in[]))\
(let(l)w for(l in[]))(let(u)w for(l in['']))(let(c)w for(u in[]))(let(u)w for(l in[]))\
(let(c)w for(l in[]))(let(l)w for(l in[]))(let(c)w for(l in[]))(let(u)w for(l in[]))\
(let(c)w for(l in[]))(let(u)w for each(l in[x]))(let(w,x)w for(u in[]))]){}\
")

View File

@ -59,10 +59,6 @@ assertEq((function(a) { let ([x,y] = a) { (function() { x += y })(); return x }
assertEq((function(a) { let ([x,y] = a) { x += y; return (function() x)() } })([1,2]), 3);
assertEq((function(a) { let ([[l, x],[m, y]] = a) { (function() { x += y })(); return x } })([[0,1],[0,2]]), 3);
assertEq((function(a) { let ([[l, x],[m, y]] = a) { x += y; return (function() x)() } })([[0,1],[0,2]]), 3);
assertEq((function(a) { return let ([x,y] = a) ((function() { x += y })(), x) })([1,2]), 3);
assertEq((function(a) { return let ([x,y] = a) (x += y, (function() x)()) })([1,2]), 3);
assertEq((function(a) { return let ([[l, x],[m, y]] = a) ((function() { x += y })(), x) })([[0,1],[0,2]]), 3);
assertEq((function(a) { return let ([[l, x],[m, y]] = a) (x += y, (function() x)()) })([[0,1],[0,2]]), 3);
assertEq((function() { let x = 3; return (function() { return x })() })(), 3);
assertEq((function() { let g = function() { return x }; let x = 3; return g() })(), 3);

View File

@ -57,47 +57,46 @@ function isReferenceError(str)
}
// let expr
test('return let (y) x;');
test('return let (x) "" + x;', 'unicorns', 'undefined');
test('return let (y = x) (y++, "" + y);', 'unicorns', 'NaN');
test('return let (y = 1) (y = x, y);');
test('return let ([] = x) x;');
test('return let (x = {a: x}) x.a;');
test('return let ({a: x} = {a: x}) x;');
test('return let ([x] = [x]) x;');
test('return let ({0: x} = [x]) x;');
test('return let ({0: []} = [[]]) x;');
test('return let ([, ] = x) x;');
test('return let ([, , , , ] = x) x;');
test('return let (x = x) x;');
test('return let (x = eval("x")) x;');
test('return let (x = (let (x = x + 1) x) + 1) x;', 1, 3);
test('return let (x = (let (x = eval("x") + 1) eval("x")) + 1) eval("x");', 1, 3);
test('return let (x = x + 1, y = x) y;');
test('return let (x = x + 1, [] = x, /*[[, , ]] = x, */y = x) y;');
test('return let ([{a: x}] = x, [, {b: y}] = x) let (x = x + 1, y = y + 2) x + y;', [{a:"p"},{b:"p"}], "p1p2");
test('return let ([] = []) x;');
test('return let ([] = [x]) x;');
test('return let ([a] = (1, [x])) a;');
test('return let ([a] = (1, x, 1, x)) a;', ['ponies']);
test('return let ([x] = [x]) x;');
test('return let ([[a, [b, c]]] = [[x, []]]) a;');
test('return let ([x, y] = [x, x + 1]) x + y;', 1, 3);
test('return let ([x, y, z] = [x, x + 1, x + 2]) x + y + z;', 1, 6);
test('return let ([[x]] = [[x]]) x;');
test('return let ([x, y] = [x, x + 1]) x;');
test('return let ([x, [y, z]] = [x, x + 1]) x;');
test('return let ([{x: [x]}, {y1: y, z1: z}] = [x, x + 1]) x;',{x:['ponies']});
test('return let (x = (3, x)) x;');
test('return let (x = x + "s") x;', 'ponie');
test('return let ([x] = (3, [x])) x;');
test('return let (y = x) function () {return eval("y");}();');
test('return eval("let (y = x) y");');
test('return let (y = x) (eval("var y = 2"), y);', 'ponies', 2);
test('"use strict";return let (y = x) (eval("var y = 2"), y);');
test('this.y = x;return let (y = 1) this.eval("y");');
test('try {let (x = x) eval("throw x");} catch (e) {return e;}');
test('try {return let (x = eval("throw x")) x;} catch (e) {return e;}');
isParseError('return let (y) x;');
isParseError('return let (x) "" + x;', 'unicorns', 'undefined');
isParseError('return let (y = x) (y++, "" + y);', 'unicorns', 'NaN');
isParseError('return let (y = 1) (y = x, y);');
isParseError('return let ([] = x) x;');
isParseError('return let (x = {a: x}) x.a;');
isParseError('return let ({a: x} = {a: x}) x;');
isParseError('return let ([x] = [x]) x;');
isParseError('return let ({0: x} = [x]) x;');
isParseError('return let ({0: []} = [[]]) x;');
isParseError('return let ([, ] = x) x;');
isParseError('return let ([, , , , ] = x) x;');
isParseError('return let (x = x) x;');
isParseError('return let (x = eval("x")) x;');
isParseError('return let (x = (let (x = x + 1) x) + 1) x;', 1, 3);
isParseError('return let (x = (let (x = eval("x") + 1) eval("x")) + 1) eval("x");', 1, 3);
isParseError('return let (x = x + 1, y = x) y;');
isParseError('return let (x = x + 1, [] = x, /*[[, , ]] = x, */y = x) y;');
isParseError('return let ([{a: x}] = x, [, {b: y}] = x) let (x = x + 1, y = y + 2) x + y;', [{a:"p"},{b:"p"}], "p1p2");
isParseError('return let ([] = []) x;');
isParseError('return let ([] = [x]) x;');
isParseError('return let ([a] = (1, [x])) a;');
isParseError('return let ([a] = (1, x, 1, x)) a;', ['ponies']);
isParseError('return let ([x] = [x]) x;');
isParseError('return let ([[a, [b, c]]] = [[x, []]]) a;');
isParseError('return let ([x, y] = [x, x + 1]) x + y;', 1, 3);
isParseError('return let ([x, y, z] = [x, x + 1, x + 2]) x + y + z;', 1, 6);
isParseError('return let ([[x]] = [[x]]) x;');
isParseError('return let ([x, y] = [x, x + 1]) x;');
isParseError('return let ([x, [y, z]] = [x, x + 1]) x;');
isParseError('return let ([{x: [x]}, {y1: y, z1: z}] = [x, x + 1]) x;',{x:['ponies']});
isParseError('return let (x = (3, x)) x;');
isParseError('return let (x = x + "s") x;', 'ponie');
isParseError('return let ([x] = (3, [x])) x;');
isParseError('return let (y = x) function () {return eval("y");}();');
isParseError('return let (y = x) (eval("var y = 2"), y);', 'ponies', 2);
isParseError('"use strict";return let (y = x) (eval("var y = 2"), y);');
isParseError('this.y = x;return let (y = 1) this.eval("y");');
isParseError('try {let (x = x) eval("throw x");} catch (e) {return e;}');
isParseError('try {return let (x = eval("throw x")) x;} catch (e) {return e;}');
isParseError('let (x = 1, x = 2) x');
isParseError('let ([x, y] = a, {a:x} = b) x');
isParseError('let ([x, y, x] = a) x');
@ -121,8 +120,8 @@ test('let ([, ] = x) {return x;}');
test('let ([, , , , ] = x) {return x;}');
test('let (x = x) {return x;}');
test('let (x = eval("x")) {return x;}');
test('let (x = (let (x = x + 1) x) + 1) {return x;}', 1, 3);
test('let (x = (let (x = eval("x") + 1) eval("x")) + 1) {return eval("x");}', 1, 3);
isParseError('let (x = (let (x = x + 1) x) + 1) {return x;}', 1, 3);
isParseError('let (x = (let (x = eval("x") + 1) eval("x")) + 1) {return eval("x");}', 1, 3);
test('let (x = x + 1, y = x) {return y;}');
test('let (x = x + 1, [] = x, [[, , ]] = x, y = x) {return y;}');
test('let ([{a: x}] = x, [, {b: y}] = x) {let (x = x + 1, y = y + 2) {return x + y;}}', [{a:"p"},{b:"p"}], "p1p2");
@ -139,7 +138,7 @@ test('let ([x, y] = [x, x + 1]) {return x;}');
test('let ([x, [y, z]] = [x, x + 1]) {return x;}');
test('let ([{x: [x]}, {y1: y, z1: z}] = [x, x + 1]) {return x;}',{x:['ponies']});
test('let (y = x[1]) {let (x = x[0]) {try {let (y = "unicorns") {throw y;}} catch (e) {return x + y;}}}', ['pon','ies']);
test('let (x = x) {try {let (x = "unicorns") eval("throw x");} catch (e) {return x;}}');
isParseError('let (x = x) {try {let (x = "unicorns") eval("throw x");} catch (e) {return x;}}');
test('let (y = x) {return function () {return eval("y");}();}');
test('return eval("let (y = x) {y;}");');
test('let (y = x) {eval("var y = 2");return y;}', 'ponies', 2);
@ -159,8 +158,8 @@ test('var [, , , , ] = x;return x;');
test('var x = x;return x;');
test('var y = y;return "" + y;', 'unicorns', 'undefined');
test('var x = eval("x");return x;');
test('var x = (let (x = x + 1) x) + 1;return x;', 1, 3);
test('var x = (let (x = eval("x") + 1) eval("x")) + 1;return eval("x");', 1, 3);
isParseError('var x = (let (x = x + 1) x) + 1;return x;', 1, 3);
isParseError('var x = (let (x = eval("x") + 1) eval("x")) + 1;return eval("x");', 1, 3);
test('var X = x + 1, y = x;return y;');
test('var X = x + 1, [] = X, [[, , ]] = X, y = x;return y;');
test('var [{a: X}] = x, [, {b: y}] = x;var X = X + 1, y = y + 2;return X + y;', [{a:"p"},{b:"p"}], "p1p2");
@ -187,8 +186,8 @@ test('if (x) {let y = x;return x;}');
test('if (x) {let [] = x;return x;}');
test('if (x) {let [, ] = x;return x;}');
test('if (x) {let [, , , , ] = x;return x;}');
test('if (x) {let y = (let (x = x + 1) x) + 1;return y;}', 1, 3);
test('if (x) {let y = (let (x = eval("x") + 1) eval("x")) + 1;return eval("y");}', 1, 3);
isParseError('if (x) {let y = (let (x = x + 1) x) + 1;return y;}', 1, 3);
isParseError('if (x) {let y = (let (x = eval("x") + 1) eval("x")) + 1;return eval("y");}', 1, 3);
test('if (x) {let X = x + 1, y = x;return y;}');
test('if (x) {let X = x + 1, [] = X, [[, , ]] = X, y = x;return y;}');
test('if (x) {let [{a: X}] = x, [, {b: Y}] = x;var XX = X + 1, YY = Y + 2;return XX + YY;}', [{a:"p"},{b:"p"}], "p1p2");
@ -232,8 +231,8 @@ test('for (;;) {return x;}');
test('for (let y = 1;;) {return x;}');
test('for (let y = 1;; ++y) {return x;}');
test('for (let y = 1; ++y;) {return x;}');
test('for (let (x = 1) x; x != 1; ++x) {return x;}');
test('for (let (x = 1, [{a: b, c: d}] = [{a: 1, c: 2}]) x; x != 1; ++x) {return x;}');
isParseError('for (let (x = 1) x; x != 1; ++x) {return x;}');
isParseError('for (let (x = 1, [{a: b, c: d}] = [{a: 1, c: 2}]) x; x != 1; ++x) {return x;}');
test('for (let [[a, [b, c]]] = [[x, []]];;) {return a;}');
test('var sum = 0;for (let y = x; y < 4; ++y) {sum += y;}return sum;', 1, 6);
test('var sum = 0;for (let x = x, y = 10; x < 4; ++x) {sum += x;}return sum;', 1, 6);
@ -280,7 +279,7 @@ test('for each (let {x: y, y: x} in [{x: x, y: x}]) {return y;}');
test('for (let x in eval("x")) {return x;}', {ponies:true});
test('for (let x in x) {return eval("x");}', {ponies:true});
test('for (let x in eval("x")) {return eval("x");}', {ponies:true});
test('for ((let (x = {y: true}) x).y in eval("x")) {return eval("x");}');
isParseError('for ((let (x = {y: true}) x).y in eval("x")) {return eval("x");}');
test('for (let i in x) {break;}return x;');
test('for (let i in x) {break;}return eval("x");');
test('for (let x in x) {break;}return x;');

View File

@ -15,9 +15,6 @@ assertEq(g.eval("clone(f)()('123ponies')"), 3);
g.f = new Function('return function(x,y) { return x.search(/a/) + y.search(/b/) };');
assertEq(g.eval("clone(f)()('12a','foo')"), 1);
g.f = new Function('return [function(x) x+2, function(y) let(z=y+1) z];');
assertEq(g.eval("let ([f,g] = clone(f)()) f(g(4))"), 7);
g.f = new Function('return function(x) { switch(x) { case "a": return "b"; case null: return "c" } };');
assertEq(g.eval("clone(f)()('a')"), "b");
assertEq(g.eval("clone(f)()(null)"), "c");

View File

@ -4,7 +4,9 @@ function f(a, b, c)
arguments.length = getMaxArgs() + 1;
g.apply(this, arr);
}
var args = [[5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], let (x = []) (x.length = getMaxArgs() + 1, x)]
let x = [];
x.length = getMaxArgs() + 1;
var args = [[5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], x]
try
{
for (var i = 0; i < args.length; i++) { arr = args[i]; f(); }

View File

@ -1,13 +0,0 @@
(function() {
(eval("\
(function() {\
let(e = eval(\"\
for(z=0;z<5;z++){}\
\"))\
(function(){\
x = e\
})()\
})\
"))()
})();
print(x)

View File

@ -14,5 +14,5 @@ g.h = function () {
};
g.eval("h();");
g.eval("(function () { let (x = 1, y = 2) h(); })();");
g.eval("(function () { h(); })();");
assertEq(hits, 2);

View File

@ -42,8 +42,6 @@ test2(' { let @@ = 0; { let y = 0; h(); } }');
test2('function f() { let @@ = 0; { let y = 0; h(); } } f();');
test2(' { for (let @@ = 0; X < 1; X++) h(); }');
test2('function f() { for (let @@ = 0; X < 1; X++) h(); } f();');
test2(' { (let (@@ = 0) let (y = 2, z = 3) h()); }');
test2('function f() { return (let (@@ = 0) let (y = 2, z = 3) h()); } f();');
test1('(function X() { h(); })();');
test1('(function X(a, b, c) { h(); })(1, 2, 3);');

View File

@ -16,7 +16,6 @@ test("{let x = 1, y = 2; h();}", 'declarative');
test("with({x: 1, y: 2}) h();", 'with');
test("(function (s) { with ({x: 1, y: 2}) h(); })();", 'with');
test("let (x = 1) { h(); }", 'declarative');
test("(let (x = 1) h());", 'declarative');
test("for (let x = 0; x < 1; x++) h();", 'declarative');
test("for (let x in h()) ;", 'object');
test("for (let x in {a:1}) h();", 'declarative');

View File

@ -18,5 +18,4 @@ var a, b, c;
test("for (a in b of c)");
test("for each (a of b)");
test("for (a of b of c)");
test("for (let (a = 1) a of b)");
test("for (let {a: 1} of b)");

View File

@ -1,21 +0,0 @@
gczeal(11);
var otherGlobal = newGlobal();
function test(str, arg, result)
{
var fun = new Function('x', str);
var code = "(function (x) { " + str + " })";
var c = clone(otherGlobal.evaluate(code));
assertEq(c.toSource(), eval(code).toSource());
}
test('return let (y) x;');
test('return let (x) "" + x;', 'unicorns', 'undefined');
test('return let (y = x) (y++, "" + y);', 'unicorns', 'NaN');
test('return let (y = 1) (y = x, y);');
test('return let ([] = x) x;');
test('return let ([, ] = x) x;');
test('return let ([, , , , ] = x) x;');
test('return let ([[]] = x) x;');
test('return let ([[[[[[[[[[[[[]]]]]]]]]]]]] = x) x;');
test('return let ([[], []] = x) x;');
test('return let ([[[[]]], [], , [], [[]]] = x) x;');

View File

@ -1,14 +0,0 @@
function TestCase(n, d, e, a) {}
function reportCompare (expected, actual, description) {
var testcase = new TestCase("unknown-test-name", description, expected, actual);
}
var status = 'Testing scope after changing obj.__proto__';
function test() {
let ( actual = [ ] ) TestCase .__proto__ = null;
reportCompare (expect, actual, status);
}
var actual = 'error';
var expect = 'error';
for (i = 0; i < 12000; i++) {
test();
}

View File

@ -1,32 +0,0 @@
var lfcode = new Array();
lfcode.push("3");
lfcode.push("\
gczeal(2);\
for (let q = 0; q < 50; ++q) {\
var w = \"r\".match(/r/);\
}\
let (eval) (function (a) {\
Function = gczeal;\
})();\
// .js\
");
lfcode.push(" // .js");
lfcode.push(" // .js");
lfcode.push(" // .js");
while (true) {
var file = lfcode.shift(); if (file == undefined) { break; }
loadFile(file)
}
function loadFile(lfVarx) {
try {
if (lfVarx.substr(-3) == ".js") {
uneval("foo");
switch (lfRunTypeId) {
case 3: function newFunc(x) { new Function(x)(); }; newFunc(lfVarx); break;
case 4: eval("(function() { " + lfVarx + " })();"); break;
}
} else if (!isNaN(lfVarx)) {
lfRunTypeId = parseInt(lfVarx);
}
} catch (lfVare) {}
}

View File

@ -1,9 +0,0 @@
let(w)(function () {
w
})
let(e)(function () {
e
})

View File

@ -1,40 +0,0 @@
try {
for (x in ['']) {
gczeal(2)
}
} catch(e) {}
try {
var x, e
p()
} catch(e) {}
try { (function() {
let(x)((function() {
let(y)((function() {
try {
let(c) o
} finally { (f, [1,2,3])
}
}))
}))
})()
} catch(e) {}
try { (function() {
if (x.w("", (function() {
t
})())) {}
})()
} catch(e) {}
try {
gczeal()
} catch(e) {}
try { (function() {
for (let w in [0, 0]) let(b)((function() {
let(x = w = [])((function() {
for (let a in []);
}))
})())
})()
} catch(e) {}
/* Don't assert with -m only. */

View File

@ -228,6 +228,7 @@ MSG_DEF(JSMSG_CURLY_AFTER_TRY, 0, JSEXN_SYNTAXERR, "missing } after try
MSG_DEF(JSMSG_CURLY_BEFORE_BODY, 0, JSEXN_SYNTAXERR, "missing { before function body")
MSG_DEF(JSMSG_CURLY_BEFORE_CATCH, 0, JSEXN_SYNTAXERR, "missing { before catch block")
MSG_DEF(JSMSG_CURLY_BEFORE_CLASS, 0, JSEXN_SYNTAXERR, "missing { before class body")
MSG_DEF(JSMSG_CURLY_BEFORE_LET, 0, JSEXN_SYNTAXERR, "missing { before let block")
MSG_DEF(JSMSG_CURLY_BEFORE_FINALLY, 0, JSEXN_SYNTAXERR, "missing { before finally block")
MSG_DEF(JSMSG_CURLY_BEFORE_SWITCH, 0, JSEXN_SYNTAXERR, "missing { before switch body")
MSG_DEF(JSMSG_CURLY_BEFORE_TRY, 0, JSEXN_SYNTAXERR, "missing { before try block")
@ -238,7 +239,6 @@ MSG_DEF(JSMSG_DEPRECATED_DELETE_OPERAND, 0, JSEXN_SYNTAXERR, "applying the 'dele
MSG_DEF(JSMSG_DEPRECATED_FLAGS_ARG, 0, JSEXN_NONE, "flags argument of String.prototype.{search,match,replace} is deprecated")
MSG_DEF(JSMSG_DEPRECATED_LET_BLOCK, 0, JSEXN_NONE, "JavaScript 1.7's let blocks are deprecated")
MSG_DEF(JSMSG_DEPRECATED_FOR_EACH, 0, JSEXN_NONE, "JavaScript 1.6's for-each-in loops are deprecated; consider using ES6 for-of instead")
MSG_DEF(JSMSG_DEPRECATED_LET_EXPRESSION, 0, JSEXN_NONE, "JavaScript 1.7's let expressions are deprecated")
MSG_DEF(JSMSG_DEPRECATED_OCTAL, 0, JSEXN_SYNTAXERR, "octal literals and octal escape sequences are deprecated")
MSG_DEF(JSMSG_DEPRECATED_PRAGMA, 1, JSEXN_NONE, "Using //@ to indicate {0} pragmas is deprecated. Use //# instead")
MSG_DEF(JSMSG_DUPLICATE_FORMAL, 1, JSEXN_SYNTAXERR, "duplicate formal argument {0}")
@ -307,7 +307,6 @@ MSG_DEF(JSMSG_SEMI_AFTER_FOR_INIT, 0, JSEXN_SYNTAXERR, "missing ; after for-
MSG_DEF(JSMSG_SEMI_BEFORE_STMNT, 0, JSEXN_SYNTAXERR, "missing ; before statement")
MSG_DEF(JSMSG_SOURCE_TOO_LONG, 0, JSEXN_RANGEERR, "source is too long")
MSG_DEF(JSMSG_STMT_AFTER_RETURN, 0, JSEXN_SYNTAXERR, "unreachable code after return statement")
MSG_DEF(JSMSG_STRICT_CODE_LET_EXPR_STMT, 0, JSEXN_ERR, "strict mode code may not contain unparenthesized let expression statements")
MSG_DEF(JSMSG_STRICT_CODE_WITH, 0, JSEXN_SYNTAXERR, "strict mode code may not contain 'with' statements")
MSG_DEF(JSMSG_STRICT_FUNCTION_STATEMENT, 0, JSEXN_SYNTAXERR, "in strict mode code, functions may be declared only at top level or immediately within another function")
MSG_DEF(JSMSG_TEMPLSTR_UNTERM_EXPR, 0, JSEXN_SYNTAXERR, "missing } in template string")

View File

@ -43,7 +43,8 @@ BEGIN_TEST(testXDR_bug506491)
"function makeClosure(s, name, value) {\n"
" eval(s);\n"
" Math.sin(value);\n"
" return let (n = name, v = value) function () { return String(v); };\n"
" let n = name, v = value;\n"
" return function () { return String(v); };\n"
"}\n"
"var f = makeClosure('0;', 'status', 'ok');\n";

View File

@ -37,7 +37,6 @@ ASTDEF(AST_THIS_EXPR, "ThisExpression", "thisExpress
ASTDEF(AST_COMP_EXPR, "ComprehensionExpression", "comprehensionExpression")
ASTDEF(AST_GENERATOR_EXPR, "GeneratorExpression", "generatorExpression")
ASTDEF(AST_YIELD_EXPR, "YieldExpression", "yieldExpression")
ASTDEF(AST_LET_EXPR, "LetExpression", "letExpression")
ASTDEF(AST_CLASS_EXPR, "ClassExpression", "classExpression")
ASTDEF(AST_EMPTY_STMT, "EmptyStatement", "emptyStatement")

View File

@ -586,7 +586,7 @@ struct JSCompartment
DeprecatedLegacyGenerator = 2, // JS 1.7+
DeprecatedExpressionClosure = 3, // Added in JS 1.8
DeprecatedLetBlock = 4, // Added in JS 1.7
DeprecatedLetExpression = 5, // Added in JS 1.7
// NO LONGER USING 5
DeprecatedNoSuchMethod = 6, // JS 1.7+
DeprecatedFlagsArgument = 7, // JS 1.3 or older
RegExpSourceProperty = 8, // ES5

View File

@ -681,8 +681,6 @@ class NodeBuilder
bool generatorExpression(HandleValue body, NodeVector& blocks, HandleValue filter,
bool isLegacy, TokenPos* pos, MutableHandleValue dst);
bool letExpression(NodeVector& head, HandleValue expr, TokenPos* pos, MutableHandleValue dst);
/*
* declarations
*/
@ -1475,24 +1473,6 @@ NodeBuilder::generatorExpression(HandleValue body, NodeVector& blocks, HandleVal
dst);
}
bool
NodeBuilder::letExpression(NodeVector& head, HandleValue expr, TokenPos* pos,
MutableHandleValue dst)
{
RootedValue array(cx);
if (!newArray(head, &array))
return false;
RootedValue cb(cx, callbacks[AST_LET_EXPR]);
if (!cb.isNull())
return callback(cb, array, expr, pos, dst);
return newNode(AST_LET_EXPR, pos,
"head", array,
"body", expr,
dst);
}
bool
NodeBuilder::letStatement(NodeVector& head, HandleValue stmt, TokenPos* pos, MutableHandleValue dst)
{
@ -1800,7 +1780,7 @@ class ASTSerializer
bool declaration(ParseNode* pn, MutableHandleValue dst);
bool variableDeclaration(ParseNode* pn, bool lexical, MutableHandleValue dst);
bool variableDeclarator(ParseNode* pn, MutableHandleValue dst);
bool let(ParseNode* pn, bool expr, MutableHandleValue dst);
bool letBlock(ParseNode* pn, MutableHandleValue dst);
bool importDeclaration(ParseNode* pn, MutableHandleValue dst);
bool importSpecifier(ParseNode* pn, MutableHandleValue dst);
bool exportDeclaration(ParseNode* pn, MutableHandleValue dst);
@ -2144,7 +2124,7 @@ ASTSerializer::variableDeclarator(ParseNode* pn, MutableHandleValue dst)
}
bool
ASTSerializer::let(ParseNode* pn, bool expr, MutableHandleValue dst)
ASTSerializer::letBlock(ParseNode* pn, MutableHandleValue dst)
{
MOZ_ASSERT(pn->pn_pos.encloses(pn->pn_left->pn_pos));
MOZ_ASSERT(pn->pn_pos.encloses(pn->pn_right->pn_pos));
@ -2168,11 +2148,8 @@ ASTSerializer::let(ParseNode* pn, bool expr, MutableHandleValue dst)
}
RootedValue v(cx);
return expr
? expression(letBody->pn_expr, &v) &&
builder.letExpression(dtors, v, &pn->pn_pos, dst)
: statement(letBody->pn_expr, &v) &&
builder.letStatement(dtors, v, &pn->pn_pos, dst);
return statement(letBody->pn_expr, &v) &&
builder.letStatement(dtors, v, &pn->pn_pos, dst);
}
bool
@ -2442,7 +2419,7 @@ ASTSerializer::statement(ParseNode* pn, MutableHandleValue dst)
return declaration(pn, dst);
case PNK_LETBLOCK:
return let(pn, false, dst);
return letBlock(pn, dst);
case PNK_LET:
case PNK_CONST:
@ -3192,9 +3169,6 @@ ASTSerializer::expression(ParseNode* pn, MutableHandleValue dst)
LOCAL_ASSERT(pn->pn_count == 1);
return comprehension(pn->pn_head, dst);
case PNK_LETEXPR:
return let(pn, true, dst);
case PNK_CLASS:
return classDefinition(pn, true, dst);

View File

@ -1,40 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 344262;
var summary = 'Variables bound by let statement/expression';
var actual = '';
var expect = 0;
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
function f() {
var a = [];
for (var i = 0; i < 10; i++) {
a[i] = let (j = i) function () { return j; };
var b = [];
for (var k = 0; k <= i; k++)
b.push(a[k]());
print(b.join());
}
actual = a[0]();
print(actual);
}
f();
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,30 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 345542;
var summary = 'Use let in let-scoped loops';
var actual = 'No Crash';
var expect = 'No Crash';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
var f = [];
for (let i = 0; i < 1; i++) f[i] = let (n = i) function () { return n; };
for (let i = 0; i < 2; i++) f[i] = let (n = i) function () { return n; };
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,30 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 349653;
var summary = 'Do not assert: OBJ_GET_CLASS(cx, obj) == &js_ArrayClass';
var actual = 'No Crash';
var expect = 'No Crash';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
void ({y: true ? [1 for (x in [2])] : 3 })
reportCompare(expect, actual, summary);
let (a) true ? [2 for each (z in function(id) { return id })] : 3;
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,36 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 351497;
var summary = 'Do not assert for(let (w) x in y)';
var actual = 'No Crash';
var expect = 'No Crash';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
expect = /SyntaxError: (invalid for\/in left-hand side|missing variable name)/;
try
{
eval('for(let (w) x in y) { }');
}
catch(ex)
{
actual = ex + '';
}
reportMatch(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,38 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 352185;
var summary = 'Do not assert on switch with let';
var actual = 'No Crash';
var expect = 'No Crash';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
try
{
eval('switch(let (a) 2) { case 0: let b; }');
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
summary = 'let declaration must be direct child of block or top-level implicit block';
expect = 'SyntaxError';
actual = ex.name;
}
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -21,28 +21,6 @@ function test()
printBugNumber(BUGNUMBER);
printStatus (summary);
expect = /TypeError: 0 is not a function/;
try
{
[let (x = 3, y = 4) x].map(0);
}
catch(ex)
{
actual = ex + '';
}
reportMatch(expect, actual, '[let (x = 3, y = 4) x].map(0)');
expect = /TypeError: (p.z = \[let \(x = 3, y = 4\) x\]|.*Array.*) is not a function/;
try
{
var p = {}; (p.z = [let (x = 3, y = 4) x])();
}
catch(ex)
{
actual = ex + '';
}
reportMatch(expect, actual, 'p = {}; (p.z = [let (x = 3, y = 4) x])()');
expect = /TypeError: (p.z = \(let \(x\) x\)|.*Undefined.*) is not a function/;
try
{

View File

@ -1,62 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 352616;
var summary = 'Do not Crash reporting error with |for..in| and |let|';
var actual = 'No Crash';
var expect = 'No Crash';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
expect = /TypeError: (.+\.c is not a function|Cannot find function c.)/;
actual = 'No Error';
try
{
for(a in (let (b=1) 2).c(3)) { };
}
catch(ex)
{
actual = ex + '';
}
reportMatch(expect, actual, summary + ': 1');
expect = /TypeError: (.+\.c is not a function|Cannot find function c.)/;
actual = 'No Error';
try
{
for(a in (let (b=1,d=2) 2).c(3)) { };
}
catch(ex)
{
actual = ex + '';
}
reportMatch(expect, actual, summary + ': 2');
expect = /TypeError: (.+\.c is not a function|Cannot find function c.)/;
actual = 'No Error';
try
{
for(a in (let (b=1,d=2) 2).c(3)) { };
}
catch(ex)
{
actual = ex + '';
}
reportMatch(expect, actual, summary + ': 3');
exitFunc ('test');
}

View File

@ -20,13 +20,10 @@ function test()
printBugNumber(BUGNUMBER);
printStatus (summary);
printStatus('This bug can only be verified with a WAY_TOO_MUCH_GC build');
let (x = [].map(function () {})) { x; }
reportCompare(expect, actual, summary + ': 1');
let (x = [].map(function () {})) 3
reportCompare(expect, actual, summary + ': 2');
var g = function() {};
(function() { let x = [].map(function () {}); g(x); })()
reportCompare(expect, actual, summary + ': 3');

View File

@ -1,28 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 349624;
var summary = 'let in initial-value expression for another let';
var actual = 'No Crash';
var expect = 'No Crash';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
let(y = let (x) 4) 3
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,28 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 349818;
var summary = 'let expression should not assert';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
let (x=3) x;
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,41 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 421806;
var summary = 'Do not assert: *pcstack[pcdepth - 1] == JSOP_ENTERBLOCK';
var actual = 'No Crash';
var expect = 'No Crash';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
try
{
let([] = c) 1;
}
catch(ex)
{
try
{
this.a.b;
}
catch(ex2)
{
}
}
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,37 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 353454;
var summary = 'Do not assert with regexp iterator';
var actual = 'No Crash';
var expect = 'No Crash';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
actual = "no exception";
try
{
expect = 'TypeError';
var obj = {a: 5}; obj.__iterator__ = /x/g; for(x in y = let (z) obj) { }
}
catch(ex)
{
actual = ex instanceof TypeError ? 'TypeError' : "" + ex;
}
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -107,18 +107,6 @@ function test()
}
reportCompare(expect, actual, summary + ': 7');
expect = 'TypeError: ++x is not a function';
actual = 'No Crash';
try
{
let (x=3) ((++x)())
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary + ': 8');
expect = 'ReferenceError: x.y is not defined';
actual = 'No Crash';
try

View File

@ -1,36 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 352870;
var summary = 'Do not assert for crazy huge testcases';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
expect = /TypeError: .+\.g (has no properties|is undefined)/;
actual = '';
try
{
switch(4) { case [(let (y = [].j(5)) ({}))
for (p in ([1,2,3,4].g).v({},((w).y(z, [1]))))]: } }
catch(ex)
{
actual = ex + '';
}
reportMatch(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,27 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 361566;
var summary = 'Do not assert: !fp->blockChain || OBJ_GET_PARENT(cx, obj) == fp->blockChain';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
try { let([] = z) 3; } catch(ex) { }
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,34 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 373828;
var summary = 'Do not assert: op == JSOP_LEAVEBLOCKEXPR ? ' +
'fp->spbase + OBJ_BLOCK_DEPTH(cx, obj) == sp - 1 : fp->spbase + OBJ_BLOCK_DEPTH(cx, obj) == sp';
var actual = 'No Crash';
var expect = 'No Crash';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
try
{
for(let y in [5,6]) let([] = [1]) (function(){ }); d;
}
catch(ex)
{
}
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,28 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 387951;
var summary = 'Do not assert: cg->stackDepth >= 0';
var actual = 'No Crash';
var expect = 'No Crash';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
with(delete let (functional) null ? 1 : {}){}
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -9,7 +9,9 @@ printBugNumber(BUGNUMBER);
printStatus(summary);
var expected = '1,2,3,4';
var actual = let (a = 1, [b,c] = [2,3], d = 4) ( String([a,b,c,d]) );
let a = 1, [b,c] = [2,3], d = 4;
var actual = String([a,b,c,d]);
reportCompare(expected, actual, 'destructuring assignment in let');

View File

@ -1,37 +0,0 @@
// |reftest| skip -- obsolete test
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 420399;
var summary = 'Let expression error involving undefined';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
expect = /TypeError: \(let \(a = undefined\) a\) (is undefined|has no properties)/;
try
{
(let (a=undefined) a).b = 3;
}
catch(ex)
{
actual = ex + '';
}
reportMatch(expect, actual, summary);
exitFunc ('test');
}

View File

@ -51,8 +51,6 @@ needParens(13, "for (;;xx) { }");
needParens(14, "for (i in xx) { }");
needParens(15, "throw xx");
needParens(16, "try { } catch (e if xx) { }");
needParens(17, "let (x=3) xx");
needParens(18, "let (x=xx) 3");
// Function calls
doesNotNeedParens(19, "f(xx);");

View File

@ -3,7 +3,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 667131;
var summary = 'yield ignored if maybeNoteLegacyGenerator called too late';
@ -19,18 +18,10 @@ function reported1() {
(function(){})([yield[]], (""))
}
function reported2() {
(function(){})(let(w = "") yield, (e))
}
function simplified1() {
print([yield], (0))
}
function simplified2() {
print(let(w) yield, (0))
}
function f1(a) { [x for (x in yield) for (y in (a))] }
function f2(a) { [x for (x in yield) if (y in (a))] }
function f3(a) { ([x for (x in yield) for (y in (a))]) }
@ -39,16 +30,12 @@ function f4(a) { ([x for (x in yield) if (y in (a))]) }
function f7() { print({a:yield},(0)) }
function f8() { ([yield], (0)) }
function f9() { (let(w)yield, (0)) }
testGenerator(reported1, "reported function with array literal");
testGenerator(reported2, "reported function with let-expression");
testGenerator(simplified1, "reported function with array literal, simplified");
testGenerator(simplified2, "reported function with let-expression, simplified");
testGenerator(f1, "top-level array comprehension with paren expr in for-block");
testGenerator(f2, "top-level array comprehension with paren expr in if-block");
testGenerator(f3, "parenthesized array comprehension with paren expr in for-block");
testGenerator(f4, "parenthesized array comprehension with paren expr in if-block");
testGenerator(f7, "object literal");
testGenerator(f8, "array literal in paren exp");
testGenerator(f9, "let-expression in paren exp");

View File

@ -1,28 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 453492;
var summary = 'Do not assert: op == JSOP_ENUMELEM || op == JSOP_ENUMCONSTELEM';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
print(function() { [(let(a)1)[2]] = 3; });
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,28 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 464092;
var summary = 'Do not assert: OBJ_IS_CLONED_BLOCK(obj)';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
let (a) 'b'.replace(/b/g, function() { c = this; }); c.d = 3; c.d;
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,35 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 464092;
var summary = 'Censor block objects';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
try
{
let (a) 'b'.replace(/b/g, function() c = this );
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,40 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 472528;
var summary = 'Do not assert: !js_IsActiveWithOrBlock(cx, fp->scopeChain, 0)';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
jit(true);
try
{
for (var i = 0; i < 4; ++i) {
for (let j = 0; j < 2; ++j) { }
let (x) (function(){});
}
}
catch(ex)
{
}
jit(false);
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,40 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 472528;
var summary = 'Do not assert: !fp->blockChain';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
jit(true);
try
{
for (let i = 0; i < 4; ++i) {
for (let j = 0; j < 2; ++j) { }
let (x) (function(){});
}
}
catch(ex)
{
}
jit(false);
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,40 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 472703;
var summary = 'Do not assert: regs.sp[-1] == OBJECT_TO_JSVAL(fp->scopeChain)';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
jit(true);
try
{
eval(
'for (var z = 0; z < 2; ++z) { with({}) for(let y in [1, null]); let(x)' +
'(function(){})(); }'
);
}
catch(ex)
{
}
jit(false);
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,36 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 420399;
var summary = 'Let expression error involving undefined';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
expect = "TypeError: a is undefined";
try
{
(let (a=undefined) a).b = 3;
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -31,11 +31,6 @@ function test()
function f() { var x; eval("let x, x;"); }
f();
// Assertion failure: fp2->fun && fp2->script,
// at ../jsinterp.cpp:5589
//
eval("let(x) function(){ x = this; }()");
reportCompare(expect, actual, summary);
exitFunc ('test');

View File

@ -43,13 +43,6 @@ function test()
(function(q){return q;} for each (\u3056 in []))
// =====
for(
const NaN = undefined;
this.__defineSetter__("x4", function(){});
(eval("", (p={})))) let ({} = (((x ))(function ([]) {})), x1) y;
// =====
function f(){ var c; eval("{var c = NaN, c;}"); }

View File

@ -72,21 +72,6 @@ function test()
{
}
// =====
if (typeof window == 'undefined')
global = this;
else
global = window;
try
{
eval('(function(){with(global){1e-81; }for(let [x, x3] = global -= x in []) function(){}})();');
}
catch(ex)
{
}
// =====
try
{
@ -114,11 +99,6 @@ function test()
{
}
// =====
var f = new Function("try { with({}) x = x; } catch(\u3056 if (function(){x = x2;})()) { let([] = [1.2e3.valueOf(\"number\")]) ((function(){})()); } ");
"" + f;
// =====
var f = new Function("[] = [( '' )()];");

View File

@ -26,20 +26,6 @@ function test()
// =====
((function x()x in []) for (y in []))
//Assertion failure: lexdep->frameLevel() <= funbox->level, at ../jsparse.cpp:1778
// Opt crash [@ JSCompiler::setFunctionKinds]
// =====
let(x=[]) function(){try {x} catch(x) {} }
// Assertion failure: cg->upvars.lookup(atom), at ../jsemit.cpp:2034
// =====
try
{
eval('for(let [y] = (let (x) (y)) in []) function(){}');
}
catch(ex)
{
}
// Assertion failure: !(pnu->pn_dflags & PND_BOUND), at ../jsemit.cpp:1818
// =====

View File

@ -1,31 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 452498;
var summary = 'TM: upvar2 regression tests';
var actual = '';
var expect = '';
//------- Comment #178 From Gary Kwong
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
// Assertion failure: slot < fp2->script->nfixed, at ../jsinterp.cpp:5610
eval("with({}) let(x=[])(function(){x})()");
reportCompare(expect, actual, summary);
exitFunc ('test');
}

View File

@ -1,12 +0,0 @@
// -*- indent-tabs-mode: nil; js-indent-level: 4 -*-
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/
// Don't assert trying to parse this.
let(x = (x(( function() {
return { e: function() { e in x } };
}))
for (x in [])))
true;
reportCompare(true, true);

View File

@ -232,9 +232,6 @@ function genExpr(body, blocks, filter, style) {
function graphExpr(idx, body) {
return Pattern({ type: "GraphExpression", index: idx, expression: body });
}
function letExpr(head, body) {
return Pattern({ type: "LetExpression", head: head, body: body });
}
function idxExpr(idx) {
return Pattern({ type: "GraphIndexExpression", index: idx });
}

View File

@ -138,7 +138,6 @@ return {
comprehensionExpression: reject,
generatorExpression: reject,
yieldExpression: reject,
letExpression: reject,
emptyStatement: () => ["EmptyStmt", {}],
blockStatement: function(stmts) {

View File

@ -42,7 +42,6 @@ assertGlobalExpr("this", 14, { thisExpression: () => 14 });
assertGlobalExpr("[x for (x in y)]", 17, { comprehensionExpression: () => 17 });
assertGlobalExpr("(x for (x in y))", 18, { generatorExpression: () => 18 });
assertGlobalExpr("(function() { yield 42 })", genFunExpr(null, [], blockStmt([exprStmt(19)])), { yieldExpression: () => 19 });
assertGlobalExpr("(let (x) x)", 20, { letExpression: () => 20 });
assertGlobalStmt("switch (x) { case y: }", switchStmt(ident("x"), [1]), { switchCase: () => 1 });
assertGlobalStmt("try { } catch (e) { }", 2, { tryStatement: (b, g, u, f) => u, catchClause: () => 2 });

View File

@ -14,30 +14,6 @@ assertBlockDecl("let {x:y} = foo;", letDecl([{ id: objPatt([assignProp("x", iden
assertDecl("const {x:y} = foo;", constDecl([{ id: objPatt([assignProp("x", ident("y"))]),
init: ident("foo") }]));
// let expressions
assertExpr("(let (x=1) x)", letExpr([{ id: ident("x"), init: lit(1) }], ident("x")));
assertExpr("(let (x=1,y=2) y)", letExpr([{ id: ident("x"), init: lit(1) },
{ id: ident("y"), init: lit(2) }],
ident("y")));
assertExpr("(let (x=1,y=2,z=3) z)", letExpr([{ id: ident("x"), init: lit(1) },
{ id: ident("y"), init: lit(2) },
{ id: ident("z"), init: lit(3) }],
ident("z")));
assertExpr("(let (x) x)", letExpr([{ id: ident("x"), init: null }], ident("x")));
assertExpr("(let (x,y) y)", letExpr([{ id: ident("x"), init: null },
{ id: ident("y"), init: null }],
ident("y")));
assertExpr("(let (x,y,z) z)", letExpr([{ id: ident("x"), init: null },
{ id: ident("y"), init: null },
{ id: ident("z"), init: null }],
ident("z")));
assertExpr("(let (x = 1, y = x) y)", letExpr([{ id: ident("x"), init: lit(1) },
{ id: ident("y"), init: ident("x") }],
ident("y")));
assertError("(let (x = 1, x = 2) x)", TypeError);
// let statements
assertStmt("let (x=1) { }", letStmt([{ id: ident("x"), init: lit(1) }], blockStmt([])));

View File

@ -1,36 +0,0 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
* Contributor: Dave Herman
*/
function earlyError(src) {
var threw;
try {
eval(src);
threw = false;
} catch (expected) {
threw = true;
}
assertEq(threw, true);
}
earlyError("'use strict'; let (x) 42;");
earlyError("function f() { 'use strict'; let (x) 42;");
earlyError("'use strict'; function id(x) { return x } let (a=1) a ? f : x++(42);");
earlyError("function id(x) { return x } function f() { 'use strict'; let (a=1) a ? f : x++(42); }");
earlyError("'use strict'; let (x=2, y=3) x=3, y=13");
earlyError("function f() { 'use strict'; let (x=2, y=3) x=3, y=13 }");
x = "global";
(let (x=2, y=3) x=3, y=13);
assertEq(x, "global");
assertEq(y, 13);
// https://bugzilla.mozilla.org/show_bug.cgi?id=569464#c12
g = (let (x=7) x*x for each (x in [1,2,3]));
for (let y in g) {
assertEq(y, 49);
}
reportCompare(0, 0, "In strict mode, let expression statements are disallowed.");

Some files were not shown because too many files have changed in this diff Show More