unexpected 'await' keyword on function declaration#1187
Open
HicaroD wants to merge 6 commits intoquick-lint:masterfrom
Open
unexpected 'await' keyword on function declaration#1187HicaroD wants to merge 6 commits intoquick-lint:masterfrom
HicaroD wants to merge 6 commits intoquick-lint:masterfrom
Conversation
strager
requested changes
Jan 21, 2024
Comment on lines
3606
to
3607
| [[qljs::message("Unexpected 'await' keyword on function declaration. Maybe you meant 'async'?", | ||
| ARG(await_keyword))]] // |
Collaborator
There was a problem hiding this comment.
You should follow the syntactic style of existing diagnostics (like E0178) instead:
Suggested change
| [[qljs::message("Unexpected 'await' keyword on function declaration. Maybe you meant 'async'?", | |
| ARG(await_keyword))]] // | |
| [[qljs::message("unexpected 'await' keyword on function declaration; maybe you meant 'async'?", | |
| ARG(await_keyword))]] // |
| // Copyright (C) 2020 Matthew "strager" Glazar | ||
| // See end of file for extended copyright information. | ||
|
|
||
| #include <cstdio> |
| this->diag_reporter_->report( | ||
| Diag_Unexpected_Await_On_Function_Declaration{ | ||
| .await_keyword = await_token.span()}); | ||
| } |
Collaborator
There was a problem hiding this comment.
Must fix: Your special handling of function is wrong in a few ways:
await function foo() {}();is parsed incorrectly. You have a test for it, buttest_parse_and_visit_statementdoesn't assert that the whole input is parsed. (It probably should... I should fix that.) This code is parsingawait function foo() {}as a statement, leaving();as a second statement (which is wrong!).await function () {}falsely reports E0061 ("missing name in function statement").
Also, adding code here in parse_and_visit_expression doesn't catch mistakes such as the following:
foo(await function() {
});parse_await_expression is probably a better place to put your logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#413