Fix to require parentheses around yield expression in argument list (351514, r=mrbkap).

This commit is contained in:
brendan%mozilla.org 2006-09-06 22:52:28 +00:00
parent fcecd128c6
commit 626f012531
2 changed files with 14 additions and 4 deletions

View File

@ -294,3 +294,4 @@ MSG_DEF(JSMSG_IN_AFTER_FOR_NAME, 211, 0, JSEXN_SYNTAXERR, "missing in after
MSG_DEF(JSMSG_BAD_ITERATOR_RETURN, 212, 2, JSEXN_TYPEERR, "{0}.{1} returned a primitive value")
MSG_DEF(JSMSG_KEYWORD_NOT_NS, 213, 0, JSEXN_SYNTAXERR, "keyword is used as namespace")
MSG_DEF(JSMSG_BAD_GENERATOR_YIELD, 214, 1, JSEXN_TYPEERR, "yield from closing generator {0}")
MSG_DEF(JSMSG_BAD_YIELD_SYNTAX, 215, 0, JSEXN_SYNTAXERR, "yield expression must be parenthesized")

View File

@ -3640,10 +3640,11 @@ Expr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
pn = pn2;
do {
#if JS_HAS_GENERATORS
if (PN_LAST(pn)->pn_type == TOK_YIELD) {
js_ReportCompileErrorNumber(cx, ts,
JSREPORT_TS | JSREPORT_ERROR,
JSMSG_SYNTAX_ERROR);
pn2 = PN_LAST(pn);
if (pn2->pn_type == TOK_YIELD) {
js_ReportCompileErrorNumber(cx, pn2,
JSREPORT_PN | JSREPORT_ERROR,
JSMSG_BAD_YIELD_SYNTAX);
return NULL;
}
#endif
@ -4121,6 +4122,14 @@ ArgumentList(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
JSParseNode *argNode = AssignExpr(cx, ts, tc);
if (!argNode)
return JS_FALSE;
#if JS_HAS_GENERATORS
if (argNode->pn_type == TOK_YIELD) {
js_ReportCompileErrorNumber(cx, argNode,
JSREPORT_PN | JSREPORT_ERROR,
JSMSG_BAD_YIELD_SYNTAX);
return NULL;
}
#endif
PN_APPEND(listNode, argNode);
} while (js_MatchToken(cx, ts, TOK_COMMA));