mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1288459 - Forbid GeneratorDeclaration as a child of LabelledStatement. r=arai
--HG-- extra : rebase_source : 7ad37e87fbc2974f33f151c66a7fa0bb9591f476
This commit is contained in:
parent
36fadecb91
commit
0bfc5e193f
@ -5809,6 +5809,17 @@ Parser<ParseHandler>::labeledItem(YieldHandling yieldHandling)
|
||||
return null();
|
||||
|
||||
if (tt == TOK_FUNCTION) {
|
||||
TokenKind next;
|
||||
if (!tokenStream.peekToken(&next))
|
||||
return null();
|
||||
|
||||
// GeneratorDeclaration is only matched by HoistableDeclaration in
|
||||
// StatementListItem, so generators can't be inside labels.
|
||||
if (next == TOK_MUL) {
|
||||
report(ParseError, false, null(), JSMSG_GENERATOR_LABEL);
|
||||
return null();
|
||||
}
|
||||
|
||||
// Per 13.13.1 it's a syntax error if LabelledItem: FunctionDeclaration
|
||||
// is ever matched. Per Annex B.3.2 that modifies this text, this
|
||||
// applies only to strict mode code.
|
||||
|
@ -261,6 +261,7 @@ MSG_DEF(JSMSG_LET_CLASS_BINDING, 0, JSEXN_SYNTAXERR, "'let' is not a valid
|
||||
MSG_DEF(JSMSG_LET_COMP_BINDING, 0, JSEXN_SYNTAXERR, "'let' is not a valid name for a comprehension variable")
|
||||
MSG_DEF(JSMSG_LEXICAL_DECL_NOT_IN_BLOCK, 1, JSEXN_SYNTAXERR, "{0} declaration not directly within block")
|
||||
MSG_DEF(JSMSG_LEXICAL_DECL_LABEL, 1, JSEXN_SYNTAXERR, "{0} declarations cannot be labelled")
|
||||
MSG_DEF(JSMSG_GENERATOR_LABEL, 0, JSEXN_SYNTAXERR, "generator functions cannot be labelled")
|
||||
MSG_DEF(JSMSG_FUNCTION_LABEL, 0, JSEXN_SYNTAXERR, "functions cannot be labelled")
|
||||
MSG_DEF(JSMSG_SLOPPY_FUNCTION_LABEL, 0, JSEXN_SYNTAXERR, "functions can only be labelled inside blocks")
|
||||
MSG_DEF(JSMSG_LINE_BREAK_AFTER_THROW, 0, JSEXN_SYNTAXERR, "no line break is allowed between 'throw' and its expression")
|
||||
|
@ -24,10 +24,7 @@ assertThrowsInstanceOf(() => Function("'use strict'; d: function w() {};"), Synt
|
||||
// Annex B.3.2 allows this in non-strict mode code.
|
||||
Function("e: function x() {};");
|
||||
|
||||
|
||||
// This *should* fail, but it doesn't because our function parsing is such a
|
||||
// centralized mess.
|
||||
Function("f: function* y() {}");
|
||||
assertThrowsInstanceOf(() => Function("f: function* y() {}"), SyntaxError);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user