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:
parent
e8b6b14be1
commit
953bb416a3
@ -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,
|
||||
|
18
test/mjsunit/regress/regress-crbug-580934.js
Normal file
18
test/mjsunit/regress/regress-crbug-580934.js
Normal 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());
|
||||
}
|
Loading…
Reference in New Issue
Block a user