archives

« Bugzilla Issues Index

#1891 — Inconsistent use of [[Construct]] and OrdinaryConstruct


The specification should either always use [[Construct]] or OrdinaryConstruct() when performing constructor calls:

`If IsConstructor(c) then call [[Construct]] internal method [...]`

or: `If IsConstructor(c) then call OrdinaryConstruct(c, ...) [...]`

I'd be in favour of using the [[Construct]] internal method because of two reasons:
- a constructor may perform custom actions in its [[Construct]] internal method, calling OrdinaryConstruct() makes it impossible to execute these actions
- OrdinaryConstruct() requires a `callable Constructor`, so non-callable Constructors cannot use OrdinaryConstruct() [*]


[*]: non-callable Constructors are not prohibited by the spec, so in theory a non-standard exotic object could implement only [[Construct]] but not [[Call]]

[[Construct]]:
11.2.2 The new Operator
11.2.4 The super Keyword
15.4.2.4 Array.from ( arrayLike , mapfn=undefined, thisArg=undefined )
15.4.3.19 Array.prototype.map ( callbackfn [ , thisArg ] )
15.4.3.20 Array.prototype.filter ( callbackfn [ , thisArg ] )
15.13.5.4.3 ArrayBuffer.prototype.slice ( start , end)
15.13.6.3.8 %TypedArray%.prototype.subarray(begin = 0, end = this.length )

OrdinaryConstruct:
15.4.3.4 Array.prototype.concat ( [ item1 [ , item2 [ , … ] ] ] )
15.4.3.10 Array.prototype.slice (start, end)
15.4.3.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [ , … ] ] ] )
15.13.6.2.2 %TypedArray%.of ( ...items )
15.13.6.2.3 %TypedArray%.from ( source , mapfn=undefined, thisArg=undefined )
15.13.6.3.13 %TypedArray%.prototype.slice ( start, end )
15.13.6.3.20 %TypedArray%.prototype.map ( callbackfn, thisArg = undefined )
15.13.6.3.21 %TypedArray%.prototype.filter ( callbackfn, thisArg = undefined )


fixed in rev19 editor's draft

All of the listed OrdinaryConstruct calls need to be [[Construct]] calls. . We should only call OrdinaryConstruct in contexts such as inside a [[Construct]] implementation were we know we are creating an ordinary object.


fixed in rev19