Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Ensure arrow functions can close over lexically-scoped variables
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
ajklein authored and Commit bot committed Jan 26, 2016
1 parent e8b6b14 commit 953bb41
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parsing/parser-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions test/mjsunit/regress/regress-crbug-580934.js
Original file line number Diff line number Diff line change
@@ -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());
}

0 comments on commit 953bb41

Please sign in to comment.