Skip to content

Commit f60048c

Browse files
caitpCommit bot
authored andcommitted
[destructuring] don't attempt to visit contents of FunctionLiterals
The parser eagerly rewrites destructuring assignments occuring in formal parameter initializers, because not doing so would cause the BindingPattern rewriting to be confused and do the wrong thing. This change prevents this rewriting from descending into the bodies of lazily parsed functions. In general, it's a mistake to descend into the bodies of function literals anyways, since they are rewritten separately on their own time, so there is no distinction made between lazily "throw away" eagerly parsed functions in the temporary parser arena, or "real" eagerly parsed functions that will be compiled. BUG=chromium:594084, v8:811 LOG=N [email protected], [email protected] Review URL: https://codereview.chromium.org/1864553002 Cr-Commit-Position: refs/heads/master@{#35277}
1 parent 6b1f753 commit f60048c

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/parsing/parser.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4394,14 +4394,18 @@ class InitializerRewriter : public AstExpressionVisitor {
43944394
scope_(scope) {}
43954395

43964396
private:
4397-
void VisitExpression(Expression* expr) {
4397+
void VisitExpression(Expression* expr) override {
43984398
RewritableExpression* to_rewrite = expr->AsRewritableExpression();
43994399
if (to_rewrite == nullptr || to_rewrite->is_rewritten()) return;
44004400

44014401
Parser::PatternRewriter::RewriteDestructuringAssignment(parser_, to_rewrite,
44024402
scope_);
44034403
}
44044404

4405+
// Code in function literals does not need to be eagerly rewritten, it will be
4406+
// rewritten when scheduled.
4407+
void VisitFunctionLiteral(FunctionLiteral* expr) override {}
4408+
44054409
private:
44064410
Parser* parser_;
44074411
Scope* scope_;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2016 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
//
5+
// Flags: --lazy --min-preparse-length=0
6+
(function() {
7+
function CRASH(defaultParameter =
8+
(function() { function functionDeclaration() { return 0; } }())) {
9+
}
10+
})();

0 commit comments

Comments
 (0)