Commit 953bb416 authored by adamk's avatar adamk Committed by Commit bot

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