Commit d9fdc86c authored by Adam Klein's avatar Adam Klein Committed by Commit Bot

[parser] Remove bit of unnecessary for-loop desugaring logic

V8 used to erroneously allow ForStatements to contain a function
declaration, but that hasn't been true since we shipped the
"--harmony-restrictive-declarations" flag 1.5 years ago.

Bug: v8:4824
Change-Id: I893b45aed468017f89c0c5964df2091bea030327
Reviewed-on: https://chromium-review.googlesource.com/621871Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47553}
parent 70c4eda5
......@@ -5811,22 +5811,12 @@ ParserBase<Impl>::ParseStandardForLoopWithLexicalDeclarations(
// for (; c; n) b
// }
//
// or, desugar
// for (; c; n) b
// into
// {
// for (; c; n) b
// }
// just in case b introduces a lexical binding some other way, e.g., if b
// is a FunctionDeclaration.
DCHECK(!impl()->IsNull(init));
BlockT block = factory()->NewBlock(nullptr, 2, false, kNoSourcePosition);
if (!impl()->IsNull(init)) {
block->statements()->Add(init, zone());
init = impl()->NullStatement();
}
block->statements()->Add(init, zone());
block->statements()->Add(loop, zone());
block->set_scope(for_scope);
loop->Initialize(init, cond, next, body);
loop->Initialize(impl()->NullStatement(), cond, next, body);
return block;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment