-
Notifications
You must be signed in to change notification settings - Fork 105
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
Are class decorators always in strict mode? #545
Comments
The decorator's definition (not its invocation) determines whether it's in strict mode, so they absolutely can be in sloppy mode. |
I'm sorry, I think my concrete question was poorly worded. The decorator as a function can be in sloppy mode, but what about the decorator invocation?. Even if
And my understanding from the spec draft is that
causes a syntax error too. |
Modes apply to function definitions; the invocation has no effect on that. However, invoking a function named yield inside a class body will certainly error. I agree that a class decorator is part of the class, and thus its local name must be valid in strict mode. |
Duplicate of #204. |
Thanks for the quick response! |
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.
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. However, I saw this test262 test that explicitly tests that the latter is a valid expression.I want to verify if decorators must be evaluated in strict mode.
The text was updated successfully, but these errors were encountered: