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}
This commit is contained in:
adamk 2016-01-26 15:10:23 -08:00 committed by Commit bot
parent e8b6b14be1
commit 953bb416a3
2 changed files with 19 additions and 1 deletions

View File

@ -3027,7 +3027,7 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
// Multiple statement body
Consume(Token::LBRACE);
bool is_lazily_parsed =
(mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation());
(mode() == PARSE_LAZILY && scope_->AllowsLazyParsing());
if (is_lazily_parsed) {
body = this->NewStatementList(0, zone());
this->SkipLazyFunctionBody(&materialized_literal_count,

View File

@ -0,0 +1,18 @@
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --min-preparse-length=0
"use strict";
{
let one = () => {
return "example.com";
};
let two = () => {
return one();
};
assertEquals("example.com", two());
}