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

fix: new diag for async/generator on getter/setter #1087

Conversation

koopiehoop
Copy link
Contributor

closes #1066

Can you check new tests? Did I place them right and do they need Spy_Visitor with EXPECT_THAT(p.visits, ...)?
And what do you think about code repetition (error_if_generator_method, error_if_async_method)? Looks like this is the only clean solution without compromising readability

@koopiehoop koopiehoop force-pushed the new_diag_async_or_generator_on_getter_or_setter branch from 8462f95 to 343c3d5 Compare September 23, 2023 19:15
@koopiehoop koopiehoop force-pushed the new_diag_async_or_generator_on_getter_or_setter branch from 0c145d8 to a8f6515 Compare September 24, 2023 01:41
Copy link
Collaborator

@strager strager left a comment

Choose a reason for hiding this comment

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

Did I place [the tests] right

Yes!

do [the tests] need Spy_Visitor with EXPECT_THAT(p.visits, ...)?

No. What you did is great.

And what do you think about code repetition

We could parameterize the function (parameter for Token_Type::star/Token_Type::kw_async + template parameter for Diag_Class_Generator_On_Getter_Or_Setter/Diag_Class_Async_On_Getter_Or_Setter), but it might not be worth the effort.

Comment on lines 3267 to 3268
[[qljs::message("'*' keyword is not allowed on getters or setters",
ARG(generator_keyword))]] //
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is a confusing message. "'*' keyword" doesn't make sense because * is not a keyword.

I think a better phrasing is: "getters and setters cannot be generators"

[[qljs::message("'*' keyword is not allowed on getters or setters",
ARG(generator_keyword))]] //
[[qljs::message("'{0}' here", ARG(getter_setter_keyword))]] //
Source_Code_Span method_start;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I think method_start is unnecessary, so I'd remove it.

Comment on lines 1158 to 1159
error_if_generator_method();
error_if_async_method();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I think "error if async method" is a misleading name. "error if async getter or setter" is more appropriate.

Suggested change
error_if_generator_method();
error_if_async_method();
error_if_generator_getter_or_setter();
error_if_async_getter_or_setter();

u8" ^^^ .getter_setter_keyword"_diag,
javascript_options);
test_parse_and_visit_statement(
u8"class C { async get myMethod() { } }"_sv, //
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@strager
Copy link
Collaborator

strager commented Sep 26, 2023

This patch looks good to me. Let me know when I should merge it.

You can ignore the CI failures. I disconnected my ARM build bot (in my home lab) because I'm moving. It'll get hooked up in a few weeks.

@koopiehoop koopiehoop force-pushed the new_diag_async_or_generator_on_getter_or_setter branch from fd0edfb to 570759c Compare September 26, 2023 18:47
@koopiehoop
Copy link
Contributor Author

Let me know when I should merge it.

All suggested fixes have been applied, if the docs for the site looks good, then you can merge

@strager
Copy link
Collaborator

strager commented Oct 11, 2023

Landed as commit be755cb. Thanks!

@strager strager closed this Oct 11, 2023
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

Successfully merging this pull request may close these issues.

10$: error on async/generator getter/setter
2 participants