« Bugzilla Issues Index

#1797 — Attach [[Construct]] when allocating function objects?

The way MakeConstructor() currently works makes it possible to access uninitialised function objects before [[Construct]] was attached. This seems quite unfortunate, maybe it's possible to refactor that part of the specification to ensure no user code runs before [[Construct]] is added.

Here's a simple test case to demonstrate this issue:

class F extends Function {
this.boundNoConstruct = this.bind(null);
this.boundConstruct = this.bind(null);

f = new F("return []");
new f; // works, [[Construct]] present
new f.boundConstruct; // works, [[Construct]] present
new f.boundNoConstruct; // throws TypeError: object is not a constructor

fixed in rev26 editor's draft.

Constructor functions now get their [[Construct]] internal method when they are allocated.

fixed in rev26