зеркало из https://github.com/mozilla/pjs.git
Back out last change, reopening bug (thanks to waldo).
This commit is contained in:
Родитель
72467c9c18
Коммит
6d0ca0452e
|
@ -2678,7 +2678,10 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||||
case TOK_FOR:
|
case TOK_FOR:
|
||||||
{
|
{
|
||||||
#if JS_HAS_BLOCK_SCOPE
|
#if JS_HAS_BLOCK_SCOPE
|
||||||
JSParseNode *pnlet = NULL;
|
JSParseNode *pnlet;
|
||||||
|
JSStmtInfo blockInfo;
|
||||||
|
|
||||||
|
pnlet = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* A FOR node is binary, left is loop control and right is the body. */
|
/* 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);
|
pn1 = Variables(cx, ts, tc);
|
||||||
#if JS_HAS_BLOCK_SCOPE
|
#if JS_HAS_BLOCK_SCOPE
|
||||||
} else if (tt == TOK_LET) {
|
} else if (tt == TOK_LET) {
|
||||||
pn1 = Statement(cx, ts, tc);
|
(void) js_GetToken(cx, ts);
|
||||||
if (pn1 && pn1->pn_arity == PN_LIST)
|
pnlet = PushLexicalScope(cx, ts, tc, &blockInfo);
|
||||||
pnlet = tc->blockNode;
|
if (!pnlet)
|
||||||
|
return NULL;
|
||||||
|
pn1 = Variables(cx, ts, tc);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
pn1 = Expr(cx, ts, tc);
|
pn1 = Expr(cx, ts, tc);
|
||||||
|
@ -3240,19 +3245,10 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||||
|
|
||||||
/* Check for a let statement or let expression. */
|
/* Check for a let statement or let expression. */
|
||||||
if (js_PeekToken(cx, ts) == TOK_LP) {
|
if (js_PeekToken(cx, ts) == TOK_LP) {
|
||||||
/*
|
pn = LetBlock(cx, ts, tc, JS_TRUE);
|
||||||
* 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));
|
|
||||||
if (!pn || pn->pn_op == JSOP_LEAVEBLOCK)
|
if (!pn || pn->pn_op == JSOP_LEAVEBLOCK)
|
||||||
return pn;
|
return pn;
|
||||||
|
|
||||||
if (tc->flags & TCF_IN_FOR_INIT)
|
|
||||||
return pn;
|
|
||||||
|
|
||||||
/* Let expressions require automatic semicolon insertion. */
|
/* Let expressions require automatic semicolon insertion. */
|
||||||
JS_ASSERT(pn->pn_type == TOK_SEMI ||
|
JS_ASSERT(pn->pn_type == TOK_SEMI ||
|
||||||
pn->pn_op == JSOP_LEAVEBLOCKEXPR);
|
pn->pn_op == JSOP_LEAVEBLOCKEXPR);
|
||||||
|
@ -3334,8 +3330,6 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||||
pn = Variables(cx, ts, tc);
|
pn = Variables(cx, ts, tc);
|
||||||
if (!pn)
|
if (!pn)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (tc->flags & TCF_IN_FOR_INIT)
|
|
||||||
return pn;
|
|
||||||
pn->pn_extra = PNX_POPVAR;
|
pn->pn_extra = PNX_POPVAR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче