archives

« Bugzilla Issues Index

#3577 — 7.3.19 SpeciesConstructor, 9.4.2.3 ArraySpeciesCreate: inconsistency in the handling of originalObj.constructor === null


7.3.19 SpeciesConstructor
Returns the default constructor in the following cases:
(a) originalObj.constructor is undefined,
(c) originalObj.constructor[@@species] is undefined or null.

9.4.2.3 ArraySpeciesCreate
Uses the default constructor in the following cases:
(a) originalObj.constructor is undefined or null,
(b) originalObj.constructor is a constructor from a different realm,
(c) originalObj.constructor[@@species] is undefined or null.

There is an inconsistency between the two abstract operations in item (a) above.

According to Bug 3524, the editor didn't want to add `null` in the case of SpeciesConstructor. In that case, we should consider removing `null` in the case of ArraySpeciesCreate.

Proposed patch: In the algorithm of ArraySpeciesCreate:
* Add step 4.d.iii: If C is null, let C be undefined.
* Change step 5: If C is undefined, return ArrayCreate(length).


fixed in rev32 editor's draft


fixed in rev32 draft


Only partially fixed: Now, in 9.4.2.3 ArraySpeciesCreate, when originalObj.constructor[@@species] is null, a TypeError will be thrown (contrarily to 7.3.19 SpeciesConstructor). [I guess I should've made explicit the implicit "and" between the two bullets at the end of Comment 0.]

* In 9.4.2.3 ArraySpeciesCreate, add step 4.d.iii: If C is null, let C be undefined.

(Alternatively, see Bug 3725 for the opposite change in 7.3.19 SpeciesConstructor.)


fixed in rev33 editor's draft


fixed in rev33