archives

« Bugzilla Issues Index

#3219 — Remove duplicate check for constructor


We have removed the duplicate property check in ES6 but we still check for duplicate "constructor" property:



14.5.1 Static Semantics: Early Errors

ClassBody : ClassElementList

It is a Syntax Error if PrototypePropertyNameList of ClassElementList contains more than one occurrence of "constructor".



Maybe we should remove this restriction too in the name of consistency?


I don't think, just like __proto__ in object literals, constructor in class definitions is a special form and not a regular property definition and semantically is quite different from
[expressionThatEvaluatesToConstrutor] () {}

If I was going to change anything, I'd make sure that trying to defining such a method was a runtime error.