archives

« Bugzilla Issues Index

#3302 — Classes with computed names can see incomplete object


Given the following class declaration

class C {
a() {}
[(console.log(C.prototype), 42]() {}
b() {}
}

The expression for the computed property name is executed in a scope where C has a binding, allowing us to see an incomplete prototype object.

This is bad for performance.

Can we change this to have the class name as a TDZ until after all the method definitions have been installed on the prototype and the constructor.


Accessing "C" during evaluation of the computed property name will throw a ReferenceError because the binding is not yet initialized (cf. 14.5.14 step 5c and 14.5.14 step 19).


Thanks André. Perfect.