80fd0b3d8a
Correctly passing the receiver depends on the Call AST node's type. Calling a parenthesized optional chain expression is parsed as a Call of an OptionalChain of a Property. Currently the computation of the type does not take optional chains of property loads into consideration, so calls of parenthesized optional chain expressions always get passed an undefined receiver. Bug: v8:10024 Change-Id: I904b0eeca2df30160def674fb32adf821403aef9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1938571 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/master@{#65252}
25 lines
782 B
JavaScript
25 lines
782 B
JavaScript
// Copyright 2019 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: --harmony-optional-chaining
|
|
|
|
const o = { m() { return this; }, p: 42 };
|
|
const p = { o: o };
|
|
|
|
function id(x) { return x; }
|
|
|
|
assertEquals(o?.m().p, 42);
|
|
assertEquals((o?.m)().p, 42);
|
|
assertEquals(o?.m(), (o?.m)());
|
|
assertEquals(p?.o?.m().p, 42);
|
|
assertEquals((p?.o?.m)().p, 42);
|
|
assertEquals(p?.o?.m(), (p?.o?.m)());
|
|
|
|
assertEquals(o?.[id('m')]().p, 42);
|
|
assertEquals((o?.[id('m')])().p, 42);
|
|
assertEquals(o?.[id('m')](), (o?.[id('m')])());
|
|
assertEquals(p?.[id('o')]?.[id('m')]().p, 42);
|
|
assertEquals((p?.[id('o')]?.[id('m')])().p, 42);
|
|
assertEquals(p?.[id('o')]?.[id('m')](), (p?.[id('o')]?.[id('m')])());
|