Follow-up to #3656 (PR #3875). After Proxy apply/construct trap dispatch landed, three built-ins/Proxy/construct cases remain:
construct/trap-is-missing-target-is-proxy.js
construct/trap-is-null-target-is-proxy.js
construct/trap-is-undefined-target-is-proxy.js
Cause
A [[Construct]] forwarded through a trap-less proxy chain to a class / bound-constructor / builtin (Array) does not honor newTarget.prototype when allocating the instance. forward_construct constructs from the target function but ignores the threaded newTarget, so instanceof newTarget, inherited getters from class X extends …, and Array subclassing fail.
Repro
class Foo { constructor(a){ this.arg = a; } }
class Bar extends Foo { get isBar(){ return true; } }
var FooProxy = new Proxy(new Proxy(Foo, {}), { construct: null });
var bar = Reflect.construct(FooProxy, [2], Bar);
// expected: bar instanceof Bar, bar.arg === 2, bar.isBar
Scope
Honor an explicit newTarget in the forwarded [[Construct]] path: allocate the instance with newTarget.prototype and run the target constructor against it (OrdinaryCreateFromConstructor semantics), including builtin subclassing (extends Array). Orthogonal to the proxy trap machinery itself.
Follow-up to #3656 (PR #3875). After Proxy apply/construct trap dispatch landed, three
built-ins/Proxy/constructcases remain:construct/trap-is-missing-target-is-proxy.jsconstruct/trap-is-null-target-is-proxy.jsconstruct/trap-is-undefined-target-is-proxy.jsCause
A
[[Construct]]forwarded through a trap-less proxy chain to a class / bound-constructor / builtin (Array) does not honornewTarget.prototypewhen allocating the instance.forward_constructconstructs from the target function but ignores the threadednewTarget, soinstanceof newTarget, inherited getters fromclass X extends …, andArraysubclassing fail.Repro
Scope
Honor an explicit
newTargetin the forwarded[[Construct]]path: allocate the instance withnewTarget.prototypeand run the target constructor against it (OrdinaryCreateFromConstructor semantics), including builtin subclassing (extends Array). Orthogonal to the proxy trap machinery itself.