archives

« Bugzilla Issues Index

#2116 — 9.5.15 [[Construct]], 9.5.16 ProxyCreate: Only set [[Construct]] when target is constructor?


The example in bug 1391 motivated to change [9.4.1.3 BoundFunctionCreate] to only assign [[Construct]] for bound functions when the original function has [[Construct]]. But the current definition for ProxyCreate makes that example invalid (*). Also NOTE 1 for 9.5.15 still states that [[Construct]] is only present for proxies when the original [[ProxyTarget]] has [[Construct]].

Maybe this needs the TC39Review flag for further discussion or was it already discussed somewhere?


(*) The example can easily be updated if testing for [[Construct]] is needed without executing [[Construct]]:

function hasConstruct(f) {
try {
Int8Array.from.call(f, {[Symbol.iterator](){ throw true; }});
} catch (e) {
return e === true;
}
}

js> hasConstruct(function () {})
true
js> hasConstruct(a => a)
false
js> hasConstruct(Math.sin)
false


fixed in rev21 editor's draft

I think it was just a that it wasn't being conditionally set


fixed in rev21 draft