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}
This commit is contained in:
parent
e04d313d9f
commit
4c3c89c1de
@ -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 {
|
||||
|
19
test/mjsunit/es6/regress/regress-4522.js
Normal file
19
test/mjsunit/es6/regress/regress-4522.js
Normal file
@ -0,0 +1,19 @@
|
||||
// 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());
|
Loading…
Reference in New Issue
Block a user