-
Notifications
You must be signed in to change notification settings - Fork 16
Clarification on duplicate getter/setter definitions #14
Comments
After looking into how V8 treats conflicting property declarations, I'd assume the above is not an error and causes P.S.: Calling decorators of elements that would normally be shadowed by later declarations becomes relevant when a decorator changes the key. |
What about the parser/compiler throwing an error in case of duplicate method/getter/setter declaration in strict mode, which class declarations always are? |
At least in V8 5.0 objects in strict mode can contain duplicate method definitions:
Also, since the first decorator can change they key, it's not even a given that there is a conflict. This can only be determined at runtime. I don't think it's possible to make this a compile time error. |
Same for classes with duplicate methods:
|
You can have duplicate methods with the later overwriting the earlier, but it was supposed to be an error to decorate getters and setters separtely (in ClassDefinitionEvaluation). I thought i wrote spec text for it, but I don't see it uploaded; I'll try to get something for this within a couple weeks. |
Just to clarify: I think the same general problem would apply if multiple It boils down to the fact that the spec wasn't specific about the exact algorithm to coalesce the getter/setter pair(s) before passing them into the decorator. edited to make that last paragraph a little easier to parse |
Agreed. I thought I wrote out spec text clarifying coalescing but now I can't find it. Maybe I left it on my other computer. I will check after I return from traveling for TC39 |
Continue tracking in tc39/proposal-decorators#52 . |
Is that paragraph meant to include cases where both a getter and a setter have a decorator but the coalesced record would only include one of them, e.g.:
I'm not 100% sure what the expected coalesced list would be in this case, e.g. if
f
would be called once or twice and with what arguments.The text was updated successfully, but these errors were encountered: