mirror of
https://github.com/classilla/tenfourfox.git
synced 2025-02-08 01:31:00 +00:00
#430: remove parenthesized yield expression requirement M1250589
This commit is contained in:
parent
0e5c0b9e5a
commit
289bb253c1
@ -7296,10 +7296,6 @@ Parser<ParseHandler>::expr(InHandling inHandling, YieldHandling yieldHandling,
|
|||||||
if (!seq)
|
if (!seq)
|
||||||
return null();
|
return null();
|
||||||
while (true) {
|
while (true) {
|
||||||
if (handler.isUnparenthesizedYieldExpression(pn)) {
|
|
||||||
report(ParseError, false, pn, JSMSG_BAD_YIELD_SYNTAX);
|
|
||||||
return null();
|
|
||||||
}
|
|
||||||
|
|
||||||
pn = assignExpr(inHandling, yieldHandling, tripledotHandling);
|
pn = assignExpr(inHandling, yieldHandling, tripledotHandling);
|
||||||
if (!pn)
|
if (!pn)
|
||||||
@ -8877,15 +8873,6 @@ Parser<ParseHandler>::argumentList(YieldHandling yieldHandling, Node listNode, b
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler.isUnparenthesizedYieldExpression(argNode)) {
|
|
||||||
TokenKind tt;
|
|
||||||
if (!tokenStream.peekToken(&tt))
|
|
||||||
return false;
|
|
||||||
if (tt == TOK_COMMA) {
|
|
||||||
report(ParseError, false, argNode, JSMSG_BAD_YIELD_SYNTAX);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if JS_HAS_GENERATOR_EXPRS
|
#if JS_HAS_GENERATOR_EXPRS
|
||||||
if (!spread) {
|
if (!spread) {
|
||||||
if (!tokenStream.matchToken(&matched, TOK_FOR))
|
if (!tokenStream.matchToken(&matched, TOK_FOR))
|
||||||
|
@ -117,14 +117,6 @@ class SyntaxParseHandler
|
|||||||
// yields |b| each time it's resumed.
|
// yields |b| each time it's resumed.
|
||||||
NodeUnparenthesizedCommaExpr,
|
NodeUnparenthesizedCommaExpr,
|
||||||
|
|
||||||
// Yield expressions currently (but not in ES6 -- a SpiderMonkey bug to
|
|
||||||
// fix) must generally be parenthesized. (See the uses of
|
|
||||||
// isUnparenthesizedYieldExpression in Parser.cpp for the rare
|
|
||||||
// exceptions.) Thus we need this to treat |yield 1, 2;| as a syntax
|
|
||||||
// error and |(yield 1), 2;| as a comma expression that will yield 1,
|
|
||||||
// then evaluate to 2.
|
|
||||||
NodeUnparenthesizedYieldExpr,
|
|
||||||
|
|
||||||
// Assignment expressions in condition contexts could be typos for
|
// Assignment expressions in condition contexts could be typos for
|
||||||
// equality checks. (Think |if (x = y)| versus |if (x == y)|.) Thus
|
// equality checks. (Think |if (x = y)| versus |if (x == y)|.) Thus
|
||||||
// we need this to treat |if (x = y)| as a possible typo and
|
// we need this to treat |if (x = y)| as a possible typo and
|
||||||
@ -305,7 +297,7 @@ class SyntaxParseHandler
|
|||||||
bool addShorthand(Node literal, Node name, Node expr) { return true; }
|
bool addShorthand(Node literal, Node name, Node expr) { return true; }
|
||||||
bool addObjectMethodDefinition(Node literal, Node name, Node fn, JSOp op) { return true; }
|
bool addObjectMethodDefinition(Node literal, Node name, Node fn, JSOp op) { return true; }
|
||||||
bool addClassMethodDefinition(Node literal, Node name, Node fn, JSOp op, bool isStatic) { return true; }
|
bool addClassMethodDefinition(Node literal, Node name, Node fn, JSOp op, bool isStatic) { return true; }
|
||||||
Node newYieldExpression(uint32_t begin, Node value, Node gen) { return NodeUnparenthesizedYieldExpr; }
|
Node newYieldExpression(uint32_t begin, Node value, Node gen) { return NodeGeneric; }
|
||||||
Node newYieldStarExpression(uint32_t begin, Node value, Node gen) { return NodeGeneric; }
|
Node newYieldStarExpression(uint32_t begin, Node value, Node gen) { return NodeGeneric; }
|
||||||
|
|
||||||
// Statements
|
// Statements
|
||||||
@ -500,10 +492,6 @@ class SyntaxParseHandler
|
|||||||
return newBinary(kind, lhs, rhs, op);
|
return newBinary(kind, lhs, rhs, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isUnparenthesizedYieldExpression(Node node) {
|
|
||||||
return node == NodeUnparenthesizedYieldExpr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isUnparenthesizedCommaExpression(Node node) {
|
bool isUnparenthesizedCommaExpression(Node node) {
|
||||||
return node == NodeUnparenthesizedCommaExpr;
|
return node == NodeUnparenthesizedCommaExpr;
|
||||||
}
|
}
|
||||||
@ -555,7 +543,6 @@ class SyntaxParseHandler
|
|||||||
// them to a generic node.
|
// them to a generic node.
|
||||||
if (node == NodeUnparenthesizedString ||
|
if (node == NodeUnparenthesizedString ||
|
||||||
node == NodeUnparenthesizedCommaExpr ||
|
node == NodeUnparenthesizedCommaExpr ||
|
||||||
node == NodeUnparenthesizedYieldExpr ||
|
|
||||||
node == NodeUnparenthesizedAssignment ||
|
node == NodeUnparenthesizedAssignment ||
|
||||||
node == NodeUnparenthesizedUnary)
|
node == NodeUnparenthesizedUnary)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,6 @@ MSG_DEF(JSMSG_BAD_FOR_LEFTSIDE, 0, JSEXN_SYNTAXERR, "invalid for-in/of le
|
|||||||
MSG_DEF(JSMSG_LEXICAL_DECL_DEFINES_LET,0, JSEXN_SYNTAXERR, "a lexical declaration can't define a 'let' binding")
|
MSG_DEF(JSMSG_LEXICAL_DECL_DEFINES_LET,0, JSEXN_SYNTAXERR, "a lexical declaration can't define a 'let' binding")
|
||||||
MSG_DEF(JSMSG_LET_STARTING_FOROF_LHS, 0, JSEXN_SYNTAXERR, "an expression X in 'for (X of Y)' must not start with 'let'")
|
MSG_DEF(JSMSG_LET_STARTING_FOROF_LHS, 0, JSEXN_SYNTAXERR, "an expression X in 'for (X of Y)' must not start with 'let'")
|
||||||
MSG_DEF(JSMSG_BAD_GENERATOR_RETURN, 1, JSEXN_TYPEERR, "generator function {0} returns a value")
|
MSG_DEF(JSMSG_BAD_GENERATOR_RETURN, 1, JSEXN_TYPEERR, "generator function {0} returns a value")
|
||||||
MSG_DEF(JSMSG_BAD_YIELD_SYNTAX, 0, JSEXN_SYNTAXERR, "yield expression must be parenthesized")
|
|
||||||
MSG_DEF(JSMSG_BAD_GENERATOR_SYNTAX, 0, JSEXN_SYNTAXERR, "generator expression must be parenthesized")
|
MSG_DEF(JSMSG_BAD_GENERATOR_SYNTAX, 0, JSEXN_SYNTAXERR, "generator expression must be parenthesized")
|
||||||
MSG_DEF(JSMSG_BAD_GENEXP_BODY, 1, JSEXN_SYNTAXERR, "illegal use of {0} in generator expression")
|
MSG_DEF(JSMSG_BAD_GENEXP_BODY, 1, JSEXN_SYNTAXERR, "illegal use of {0} in generator expression")
|
||||||
MSG_DEF(JSMSG_BAD_INCOP_OPERAND, 0, JSEXN_REFERENCEERR, "invalid increment/decrement operand")
|
MSG_DEF(JSMSG_BAD_INCOP_OPERAND, 0, JSEXN_REFERENCEERR, "invalid increment/decrement operand")
|
||||||
|
@ -25,7 +25,6 @@ const TOP_YIELD = error("yield").message;
|
|||||||
const GENERIC = error("(for)").message;
|
const GENERIC = error("(for)").message;
|
||||||
const BAD_GENERATOR_SYNTAX = error("(for (x of []) x, 1)").message;
|
const BAD_GENERATOR_SYNTAX = error("(for (x of []) x, 1)").message;
|
||||||
const MISSING_SEMI = error("yield 1").message;
|
const MISSING_SEMI = error("yield 1").message;
|
||||||
const MISSING_PAREN = error("(yield 1)").message;
|
|
||||||
const PAREN_PAREN = error("(foo").message;
|
const PAREN_PAREN = error("(foo").message;
|
||||||
const FOR_OF_PAREN = error("(for (x of y, z) w)").message;
|
const FOR_OF_PAREN = error("(for (x of y, z) w)").message;
|
||||||
|
|
||||||
@ -55,13 +54,13 @@ const cases = [
|
|||||||
// yield expressions
|
// yield expressions
|
||||||
{ expr: "yield 1", top: [MISSING_SEMI, 2], fun: [MISSING_SEMI, 2], gen: null, genexp: [GENEXP_YIELD, 2], desc: "yield w/ arg" },
|
{ expr: "yield 1", top: [MISSING_SEMI, 2], fun: [MISSING_SEMI, 2], gen: null, genexp: [GENEXP_YIELD, 2], desc: "yield w/ arg" },
|
||||||
{ expr: "1, yield 2", top: [MISSING_SEMI, 2], fun: [MISSING_SEMI, 2], gen: null, genexp: [FOR_OF_PAREN, 1], desc: "yield w/ arg at end of list" },
|
{ expr: "1, yield 2", top: [MISSING_SEMI, 2], fun: [MISSING_SEMI, 2], gen: null, genexp: [FOR_OF_PAREN, 1], desc: "yield w/ arg at end of list" },
|
||||||
{ expr: "yield 1, 2", top: [MISSING_SEMI, 2], fun: [MISSING_SEMI, 2], gen: [YIELD_PAREN, 3], genexp: [FOR_OF_PAREN, 3], desc: "yield w/ arg in list" },
|
{ expr: "yield 1, 2", top: [MISSING_SEMI, 2], fun: [MISSING_SEMI, 2], gen: null, genexp: [FOR_OF_PAREN, 3], desc: "yield w/ arg in list" },
|
||||||
{ expr: "(yield 1)", top: [MISSING_PAREN, 2], fun: [MISSING_PAREN, 2], gen: null, genexp: [GENEXP_YIELD, 2], desc: "yield w/ arg, parenthesized" },
|
{ expr: "(yield 1)", top: [PAREN_PAREN, 2], fun: [PAREN_PAREN, 2], gen: null, genexp: [GENEXP_YIELD, 2], desc: "yield w/ arg, parenthesized" },
|
||||||
{ expr: "(1, yield 2)", top: [MISSING_PAREN, 2], fun: [MISSING_PAREN, 2], gen: null, genexp: [GENEXP_YIELD, 2], desc: "yield w/ arg at end of list, parenthesized" },
|
{ expr: "(1, yield 2)", top: [PAREN_PAREN, 2], fun: [PAREN_PAREN, 2], gen: null, genexp: [GENEXP_YIELD, 2], desc: "yield w/ arg at end of list, parenthesized" },
|
||||||
{ expr: "(yield 1, 2)", top: [MISSING_PAREN, 2], fun: [MISSING_PAREN, 2], gen: [YIELD_PAREN, 3], genexp: [YIELD_PAREN, 2], desc: "yield w/ arg in list, parenthesized" },
|
{ expr: "(yield 1, 2)", top: [PAREN_PAREN, 2], fun: [PAREN_PAREN, 2], gen: null, genexp: [YIELD_PAREN, 2], desc: "yield w/ arg in list, parenthesized" },
|
||||||
|
|
||||||
// deeply nested yield expressions
|
// deeply nested yield expressions
|
||||||
{ expr: "((((yield 1))))", top: [MISSING_PAREN, 2], fun: [MISSING_PAREN, 2], gen: null, genexp: [GENEXP_YIELD, 2], desc: "deeply nested yield w/ arg" },
|
{ expr: "((((yield 1))))", top: [PAREN_PAREN, 2], fun: [PAREN_PAREN, 2], gen: null, genexp: [GENEXP_YIELD, 2], desc: "deeply nested yield w/ arg" },
|
||||||
|
|
||||||
// arguments
|
// arguments
|
||||||
{ expr: "arguments", top: null, fun: null, gen: null, genexp: null, desc: "arguments in list" },
|
{ expr: "arguments", top: null, fun: null, gen: null, genexp: null, desc: "arguments in list" },
|
||||||
|
@ -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 = 351514;
|
|
||||||
var summary = 'Finalize yield syntax to match ES4/JS2 proposal';
|
|
||||||
var actual = '';
|
|
||||||
var expect = '';
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
test();
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function test()
|
|
||||||
{
|
|
||||||
enterFunc ('test');
|
|
||||||
printBugNumber(BUGNUMBER);
|
|
||||||
printStatus (summary);
|
|
||||||
|
|
||||||
expect = /SyntaxError: yield expression must be parenthesized/;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
eval('function f() { yield g(yield 1, 2) };');
|
|
||||||
}
|
|
||||||
catch(ex)
|
|
||||||
{
|
|
||||||
actual = ex + '';
|
|
||||||
}
|
|
||||||
|
|
||||||
reportMatch(expect, actual, summary);
|
|
||||||
|
|
||||||
exitFunc ('test');
|
|
||||||
}
|
|
@ -1,166 +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 = 634472;
|
|
||||||
var summary = 'contextual restrictions for yield and arguments';
|
|
||||||
var actual = '';
|
|
||||||
var expect = '';
|
|
||||||
|
|
||||||
|
|
||||||
function error(str) {
|
|
||||||
let base;
|
|
||||||
try {
|
|
||||||
// the following line must not be broken up into multiple lines
|
|
||||||
base = (function(){try{eval('throw new Error()')}catch(e){return e.lineNumber}})(); eval(str);
|
|
||||||
return null;
|
|
||||||
} catch (e) {
|
|
||||||
e.lineNumber = e.lineNumber - base + 1;
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const JSMSG_GENEXP_YIELD = error("(function(){((yield) for (x in []))})").message;
|
|
||||||
const JSMSG_TOP_YIELD = error("yield").message;
|
|
||||||
const JSMSG_YIELD_PAREN = error("(function(){yield, 1})").message;
|
|
||||||
const JSMSG_YIELD_FOR = error("(function(){yield for})").message;
|
|
||||||
const JSMSG_BAD_GENERATOR_SYNTAX = error("(1, x for (x in []))").message;
|
|
||||||
|
|
||||||
const cases = [
|
|
||||||
// yield expressions
|
|
||||||
{ expr: "yield", top: JSMSG_TOP_YIELD, fun: null, gen: JSMSG_GENEXP_YIELD, desc: "simple yield" },
|
|
||||||
{ expr: "yield 1", top: JSMSG_TOP_YIELD, fun: null, gen: JSMSG_GENEXP_YIELD, desc: "yield w/ arg" },
|
|
||||||
{ expr: "1, yield", top: JSMSG_TOP_YIELD, fun: null, gen: JSMSG_GENEXP_YIELD, desc: "simple yield at end of list" },
|
|
||||||
{ expr: "1, yield 2", top: JSMSG_TOP_YIELD, fun: null, gen: JSMSG_GENEXP_YIELD, desc: "yield w/ arg at end of list" },
|
|
||||||
{ expr: "yield, 1", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_PAREN, gen: JSMSG_YIELD_PAREN, desc: "simple yield in list" },
|
|
||||||
{ expr: "yield 1, 2", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_PAREN, gen: JSMSG_YIELD_PAREN, desc: "yield w/ arg in list" },
|
|
||||||
{ expr: "(yield)", top: JSMSG_TOP_YIELD, fun: null, gen: JSMSG_GENEXP_YIELD, desc: "simple yield, parenthesized" },
|
|
||||||
{ expr: "(yield 1)", top: JSMSG_TOP_YIELD, fun: null, gen: JSMSG_GENEXP_YIELD, desc: "yield w/ arg, parenthesized" },
|
|
||||||
{ expr: "(1, yield)", top: JSMSG_TOP_YIELD, fun: null, gen: JSMSG_GENEXP_YIELD, desc: "simple yield at end of list, parenthesized" },
|
|
||||||
{ expr: "(1, yield 2)", top: JSMSG_TOP_YIELD, fun: null, gen: JSMSG_GENEXP_YIELD, desc: "yield w/ arg at end of list, parenthesized" },
|
|
||||||
{ expr: "(yield, 1)", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_PAREN, gen: JSMSG_YIELD_PAREN, desc: "simple yield in list, parenthesized" },
|
|
||||||
{ expr: "(yield 1, 2)", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_PAREN, gen: JSMSG_YIELD_PAREN, desc: "yield w/ arg in list, parenthesized" },
|
|
||||||
|
|
||||||
// deeply nested yield expressions
|
|
||||||
{ expr: "((((yield))))", top: JSMSG_TOP_YIELD, fun: null, gen: JSMSG_GENEXP_YIELD, desc: "deeply nested yield" },
|
|
||||||
{ expr: "((((yield 1))))", top: JSMSG_TOP_YIELD, fun: null, gen: JSMSG_GENEXP_YIELD, desc: "deeply nested yield w/ arg" },
|
|
||||||
|
|
||||||
// arguments
|
|
||||||
{ expr: "arguments", top: null, fun: null, gen: null, desc: "arguments in list" },
|
|
||||||
{ expr: "1, arguments", top: null, fun: null, gen: null, desc: "arguments in list" },
|
|
||||||
|
|
||||||
// yield in generator expressions
|
|
||||||
{ expr: "(yield for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_FOR, gen: JSMSG_YIELD_FOR, desc: "simple yield in genexp" },
|
|
||||||
{ expr: "(yield 1 for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "yield w/ arg in genexp" },
|
|
||||||
{ expr: "(yield, 1 for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_PAREN, gen: JSMSG_YIELD_PAREN, desc: "simple yield in list in genexp" },
|
|
||||||
{ expr: "(yield 1, 2 for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_PAREN, gen: JSMSG_YIELD_PAREN, desc: "yield w/ arg in list in genexp" },
|
|
||||||
{ expr: "(1, yield for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_FOR, gen: JSMSG_YIELD_FOR, desc: "simple yield at end of list in genexp" },
|
|
||||||
{ expr: "(1, yield 2 for (x in []))", top: JSMSG_TOP_YIELD, fun: { simple: JSMSG_GENEXP_YIELD, call: JSMSG_GENEXP_YIELD },
|
|
||||||
gen: JSMSG_GENEXP_YIELD, desc: "yield w/ arg at end of list in genexp" },
|
|
||||||
{ expr: "((yield) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "simple yield, parenthesized in genexp" },
|
|
||||||
{ expr: "((yield 1) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "yield w/ arg, parenthesized in genexp" },
|
|
||||||
{ expr: "(1, (yield) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "simple yield, parenthesized in list in genexp" },
|
|
||||||
{ expr: "(1, (yield 2) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "yield w/ arg, parenthesized in list in genexp" },
|
|
||||||
{ expr: "((1, yield) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "simple yield at end of list, parenthesized in genexp" },
|
|
||||||
{ expr: "((1, yield 2) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "yield w/ arg at end of list, parenthesized in genexp" },
|
|
||||||
{ expr: "(1, (2, yield) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "simple yield at end of list, parenthesized in list in genexp" },
|
|
||||||
{ expr: "(1, (2, yield 3) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "yield w/ arg at end of list, parenthesized in list in genexp" },
|
|
||||||
{ expr: "((yield, 1) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_PAREN, gen: JSMSG_YIELD_PAREN, desc: "simple yield in list, parenthesized in genexp" },
|
|
||||||
{ expr: "((yield 1, 2) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_PAREN, gen: JSMSG_YIELD_PAREN, desc: "yield w/ arg in list, parenthesized in genexp" },
|
|
||||||
{ expr: "(1, (yield, 2) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_PAREN, gen: JSMSG_YIELD_PAREN, desc: "simple yield in list, parenthesized in list in genexp" },
|
|
||||||
{ expr: "(1, (yield 2, 3) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_YIELD_PAREN, gen: JSMSG_YIELD_PAREN, desc: "yield w/ arg in list, parenthesized in list in genexp" },
|
|
||||||
|
|
||||||
// deeply nested yield in generator expressions
|
|
||||||
{ expr: "((((1, yield 2))) for (x in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "deeply nested yield in genexp" },
|
|
||||||
{ expr: "((((1, yield 2)) for (x in [])) for (y in []))", top: JSMSG_TOP_YIELD, fun: JSMSG_GENEXP_YIELD, gen: JSMSG_GENEXP_YIELD, desc: "deeply nested yield in multiple genexps" },
|
|
||||||
|
|
||||||
// arguments in generator expressions
|
|
||||||
{ expr: "(arguments for (x in []))", top: null, fun: null, gen: null, desc: "simple arguments in genexp" },
|
|
||||||
{ expr: "(1, arguments for (x in []))", top: JSMSG_BAD_GENERATOR_SYNTAX, fun: JSMSG_BAD_GENERATOR_SYNTAX, gen: JSMSG_BAD_GENERATOR_SYNTAX, desc: "arguments in list in genexp" },
|
|
||||||
{ expr: "((arguments) for (x in []))", top: null, fun: null, gen: null, desc: "arguments, parenthesized in genexp" },
|
|
||||||
{ expr: "(1, (arguments) for (x in []))", top: JSMSG_BAD_GENERATOR_SYNTAX, fun: JSMSG_BAD_GENERATOR_SYNTAX, gen: JSMSG_BAD_GENERATOR_SYNTAX, desc: "arguments, parenthesized in list in genexp" },
|
|
||||||
{ expr: "((1, arguments) for (x in []))", top: null, fun: null, gen: null, desc: "arguments in list, parenthesized in genexp" },
|
|
||||||
{ expr: "(1, (2, arguments) for (x in []))", top: JSMSG_BAD_GENERATOR_SYNTAX, fun: JSMSG_BAD_GENERATOR_SYNTAX, gen: JSMSG_BAD_GENERATOR_SYNTAX, desc: "arguments in list, parenthesized in list in genexp" },
|
|
||||||
|
|
||||||
// deeply nested arguments in generator expressions
|
|
||||||
{ expr: "((((1, arguments))) for (x in []))", top: null, fun: null, gen: null, desc: "deeply nested arguments in genexp" },
|
|
||||||
{ expr: "((((1, arguments)) for (x in [])) for (y in []))", top: null, fun: null, gen: null, desc: "deeply nested arguments in multiple genexps" },
|
|
||||||
|
|
||||||
// legal yield/arguments in nested function
|
|
||||||
{ expr: "((function() { yield }) for (x in []))", top: null, fun: null, gen: null, desc: "legal yield in nested function" },
|
|
||||||
{ expr: "((function() { arguments }) for (x in []))", top: null, fun: null, gen: null, desc: "legal arguments in nested function" },
|
|
||||||
{ expr: "((function() arguments) for (x in []))", top: null, fun: null, gen: null, desc: "legal arguments in nested expression-closure" }
|
|
||||||
];
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
test();
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function splitKeyword(str) {
|
|
||||||
return str.
|
|
||||||
replace(/yield for/, '\nyield for\n').
|
|
||||||
replace(/yield ([0-9])/, '\nyield $1\n').
|
|
||||||
replace(/yield([^ ]|$)/, '\nyield\n$1').
|
|
||||||
replace(/arguments/, '\narguments\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
function expectError1(err, ctx, msg) {
|
|
||||||
reportCompare('object', typeof err, 'exn for: ' + msg);
|
|
||||||
reportCompare(ctx, err.message, 'exn message for: ' + msg);
|
|
||||||
if (ctx !== JSMSG_BAD_GENERATOR_SYNTAX)
|
|
||||||
reportCompare(2, err.lineNumber, 'exn token for: ' + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function expectError(expr, call, wrapCtx, expect, msg) {
|
|
||||||
let exps = (typeof expect === "string")
|
|
||||||
? { simple: expect, call: expect }
|
|
||||||
: expect;
|
|
||||||
expectError1(error(wrapCtx(expr)), exps.simple, msg);
|
|
||||||
if (call)
|
|
||||||
expectError1(error(wrapCtx(call)), exps.call, 'call argument in ' + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function expectSuccess(err, msg) {
|
|
||||||
reportCompare(null, err, 'parse: ' + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function atTop(str) { return str }
|
|
||||||
function inFun(str) { return '(function(){' + str + '})' }
|
|
||||||
function inGen(str) { return '(y for (y in ' + str + '))' }
|
|
||||||
|
|
||||||
function test()
|
|
||||||
{
|
|
||||||
enterFunc ('test');
|
|
||||||
printBugNumber(BUGNUMBER);
|
|
||||||
printStatus (summary);
|
|
||||||
|
|
||||||
for (let i = 0, len = cases.length; i < len; i++) {
|
|
||||||
let {expr, top, fun, gen, desc} = cases[i];
|
|
||||||
|
|
||||||
let call = (expr[0] === "(") ? ("print" + expr) : null;
|
|
||||||
|
|
||||||
expr = splitKeyword(expr);
|
|
||||||
if (call)
|
|
||||||
call = splitKeyword(call);
|
|
||||||
|
|
||||||
if (top)
|
|
||||||
expectError(expr, call, atTop, top, 'top-level context, ' + desc);
|
|
||||||
else
|
|
||||||
expectSuccess(error(expr), 'top-level context, ' + desc);
|
|
||||||
|
|
||||||
if (fun)
|
|
||||||
expectError(expr, call, inFun, fun, 'function context, ' + desc);
|
|
||||||
else
|
|
||||||
expectSuccess(error(inFun(expr)), 'function context, ' + desc);
|
|
||||||
|
|
||||||
if (gen)
|
|
||||||
expectError(expr, call, inGen, gen, 'genexp context, ' + desc);
|
|
||||||
else
|
|
||||||
expectSuccess(error(inGen(expr)), 'genexp context, ' + desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
exitFunc ('test');
|
|
||||||
}
|
|
@ -29,11 +29,11 @@ namespace js {
|
|||||||
*
|
*
|
||||||
* https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode
|
* https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode
|
||||||
*/
|
*/
|
||||||
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 337;
|
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 338;
|
||||||
static const uint32_t XDR_BYTECODE_VERSION =
|
static const uint32_t XDR_BYTECODE_VERSION =
|
||||||
uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);
|
uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);
|
||||||
|
|
||||||
static_assert(JSErr_Limit == 436,
|
static_assert(JSErr_Limit == 435,
|
||||||
"GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or "
|
"GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or "
|
||||||
"removed MSG_DEFs from js.msg, you should increment "
|
"removed MSG_DEFs from js.msg, you should increment "
|
||||||
"XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "
|
"XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user