Skip to content

Commit 953bb41

Browse files
ajkleinCommit bot
authored andcommitted
Ensure arrow functions can close over lexically-scoped variables
ParseArrowFunctionLiteral was erroneously checking AllowsLazyCompilation rather than AllowsLazyParsing when deciding whether to parse lazily. This meant that lexically-scoped variables that had no other referents wouldn't get closed over properly. BUG=chromium:580934, v8:4255 LOG=y Review URL: https://codereview.chromium.org/1630823006 Cr-Commit-Position: refs/heads/master@{#33530}
1 parent e8b6b14 commit 953bb41

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/parsing/parser-base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3027,7 +3027,7 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
30273027
// Multiple statement body
30283028
Consume(Token::LBRACE);
30293029
bool is_lazily_parsed =
3030-
(mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation());
3030+
(mode() == PARSE_LAZILY && scope_->AllowsLazyParsing());
30313031
if (is_lazily_parsed) {
30323032
body = this->NewStatementList(0, zone());
30333033
this->SkipLazyFunctionBody(&materialized_literal_count,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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: --min-preparse-length=0
6+
7+
"use strict";
8+
{
9+
let one = () => {
10+
return "example.com";
11+
};
12+
13+
let two = () => {
14+
return one();
15+
};
16+
17+
assertEquals("example.com", two());
18+
}

0 commit comments

Comments
 (0)