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

Parse class heritage as strict mode code #9315

Merged

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Jan 11, 2019

Q                       A
Fixed Issues? Fixes #8186
Patch: Bug Fix? 👍
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: parser Spec: Classes labels Jan 11, 2019
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9754/

1 similar comment
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9754/

@nicolo-ribaudo nicolo-ribaudo added PR: Spec Compliance 👓 A type of pull request used for our changelog categories and removed PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Jan 11, 2019
@hzoo hzoo requested a review from loganfsmyth January 11, 2019 16:08
@@ -994,8 +994,16 @@ export default class StatementParser extends ExpressionParser {
this.next();
this.takeDecorators(node);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if class decorators are also technically auto-strict? The spec currently says

All parts of a ClassDeclaration or a ClassExpression are strict mode code.

and I have no idea if that is something that is meant to include decorators, or if the decorators proposal will be changing that line to specifically call out the Body and Heritage.

I could see auto-strict decorators being annoying if support for decorating things other than classes were to be considered in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The decorators please doesn't say anything about it. @littledan wdyt about it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not, because whether it’s a decorator or not is determined at invocation time, not at the time you write the function body.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What of you directly write the function inside the decorator?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood the question :-) i believe without additional specification, it’s just like any other function - inherits strict from the lexical context or uses the pragma to turn it on.

@nicolo-ribaudo
Copy link
Member Author

I will merge this for now, if you are interested in the strictness of decorators you can watch tc39/proposal-decorators#204.

@nicolo-ribaudo nicolo-ribaudo merged commit 3e4b608 into babel:master Jan 12, 2019
@nicolo-ribaudo nicolo-ribaudo deleted the parser-class-extends-strict branch January 12, 2019 13:54
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Spec Compliance 👓 A type of pull request used for our changelog categories Spec: Classes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Class heritage should be evaluated as strict code
5 participants