Fix CheckDestructuring to reject array comprehensions (which start out as array initialisers) right away (350279, r=mrbkap).

This commit is contained in:
brendan%mozilla.org 2006-09-07 04:10:46 +00:00
parent de61177a24
commit 1a11edec95
2 changed files with 7 additions and 0 deletions

View File

@ -295,3 +295,4 @@ MSG_DEF(JSMSG_BAD_ITERATOR_RETURN, 212, 2, JSEXN_TYPEERR, "{0}.{1} returned a
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")
MSG_DEF(JSMSG_ARRAY_COMP_LEFTSIDE, 216, 0, JSEXN_SYNTAXERR, "invalid array comprehension left-hand side")

View File

@ -2082,6 +2082,12 @@ CheckDestructuring(JSContext *cx, BindData *data,
JSParseNode *lhs, *rhs, *pn, *pn2;
uint32 count;
if (left->pn_type == TOK_ARRAYCOMP) {
js_ReportCompileErrorNumber(cx, left, JSREPORT_PN | JSREPORT_ERROR,
JSMSG_ARRAY_COMP_LEFTSIDE);
return JS_FALSE;
}
ok = JS_TRUE;
fpvd.table.ops = NULL;
lhs = left->pn_head;