archives

« Bugzilla Issues Index

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


The way 8.3.16.10 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 {
constructor(...args){
this.boundNoConstruct = this.bind(null);
super(...args);
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