Commit 4c3c89c1 authored by adamk's avatar adamk Committed by Commit bot

Properly handle direct evals referencing super in arrow functions

The fix is to broaden the set of cases for when NeedsHomeObject()
returns true. Note that this is broader than it needs to be (since,
e.g., non-arrow function scopes inside a method can't reference
super). But we don't track the types of inner scopes at the moment,
so this is the best we can do.

R=rossberg@chromium.org
BUG=v8:4522
LOG=n

Review URL: https://codereview.chromium.org/1411093008

Cr-Commit-Position: refs/heads/master@{#31659}
parent e04d313d
......@@ -357,9 +357,10 @@ class Scope: public ZoneObject {
bool NeedsHomeObject() const {
return scope_uses_super_property_ ||
(scope_calls_eval_ && (IsConciseMethod(function_kind()) ||
IsAccessorFunction(function_kind()) ||
IsClassConstructor(function_kind())));
((scope_calls_eval_ || inner_scope_calls_eval_) &&
(IsConciseMethod(function_kind()) ||
IsAccessorFunction(function_kind()) ||
IsClassConstructor(function_kind())));
}
const Scope* NearestOuterEvalScope() const {
......
// Copyright 2015 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.
"use strict";
class C {
foo() {
return 42;
}
}
class D extends C {
foo() {
return (() => eval("super.foo()"))();
}
}
assertEquals(42, new D().foo());
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