Back out last change, reopening bug (thanks to waldo).

This commit is contained in:
brendan%mozilla.org 2006-09-03 06:29:20 +00:00
Родитель 72467c9c18
Коммит 6d0ca0452e
1 изменённых файлов: 10 добавлений и 16 удалений

Просмотреть файл

@ -2678,7 +2678,10 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
case TOK_FOR:
{
#if JS_HAS_BLOCK_SCOPE
JSParseNode *pnlet = NULL;
JSParseNode *pnlet;
JSStmtInfo blockInfo;
pnlet = NULL;
#endif
/* A FOR node is binary, left is loop control and right is the body. */
@ -2729,9 +2732,11 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
pn1 = Variables(cx, ts, tc);
#if JS_HAS_BLOCK_SCOPE
} else if (tt == TOK_LET) {
pn1 = Statement(cx, ts, tc);
if (pn1 && pn1->pn_arity == PN_LIST)
pnlet = tc->blockNode;
(void) js_GetToken(cx, ts);
pnlet = PushLexicalScope(cx, ts, tc, &blockInfo);
if (!pnlet)
return NULL;
pn1 = Variables(cx, ts, tc);
#endif
} else {
pn1 = Expr(cx, ts, tc);
@ -3240,19 +3245,10 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
/* Check for a let statement or let expression. */
if (js_PeekToken(cx, ts) == TOK_LP) {
/*
* The TOK_FOR case above calls Statement to handle the first part
* of a 'for (let ...; cond; update) body' loop, so treat this let
* as an expression, not a statement, and skip automatic semicolon
* insertion by returning early.
*/
pn = LetBlock(cx, ts, tc, !(tc->flags & TCF_IN_FOR_INIT));
pn = LetBlock(cx, ts, tc, JS_TRUE);
if (!pn || pn->pn_op == JSOP_LEAVEBLOCK)
return pn;
if (tc->flags & TCF_IN_FOR_INIT)
return pn;
/* Let expressions require automatic semicolon insertion. */
JS_ASSERT(pn->pn_type == TOK_SEMI ||
pn->pn_op == JSOP_LEAVEBLOCKEXPR);
@ -3334,8 +3330,6 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
pn = Variables(cx, ts, tc);
if (!pn)
return NULL;
if (tc->flags & TCF_IN_FOR_INIT)
return pn;
pn->pn_extra = PNX_POPVAR;
break;
}