Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorators: Class decorators are part of the class and their local names must be valid in strict mode. #4238

Open
lpardosixtosMs opened this issue Sep 25, 2024 · 0 comments

Comments

@lpardosixtosMs
Copy link
Contributor

The decorators spec PR has the following note at the bottom of the Class Definition secition (15.8):

A class definition is always strict mode code.

The existing spec also specifies that "All parts of a ClassDeclaration or a ClassExpression are strict mode code." Given that DecoratorList is part of ClassDeclaration and ClassExpression, I understand that decorators are in strict mode too.

ClassDeclaration[Yield, Await, Default] :
  DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await]

ClassExpression[Yield, Await] :
  DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await]opt ClassTail[?Yield, ?Await]

As a consequence expressions like @yield class C{} or @yield() class C{} are not allowed because "yield" as an IdentifierReference is not allowed in strict mode, contradicting these tests:

Related issue in the decorators proposal:
tc39/proposal-decorators#545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant