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
await
should be a keyword in a non-async local function inside an async method
#25448
Comments
Just a note about VB: there the spec says
and the implementation matches that. |
The question is how to interpret this:
If i have: async void M() {
Func<Task> f = () => { /*here*/ };
} in 'here' am i inside an async function? I don't personally think so. I think i'm "inside a non-async function". it seems 'strange' to me that the modifiers of a much outer function reach 'into' a deeper function. I agree 'inside' is vague and can be interpreted either way. But it doesn't seem sensible to me to take teh current parser interpretation. instead, each function scope is 'fresh', with its own modifiers defining how it should parse. Note: this is also how TS/JS view the world. I can check other languages later tonight. |
My point is this: i don't want to argue the meaning of the current phrasing. I think it's pretty vague and confusing (what does 'inside' mean) and can be rightfully interpreted in multiple ways.. Instead, i would just things to be explicit in the spec, i.e.:
i.e. the spec should be clearer what it uses words like 'contained' and 'inside'. -- Note: i would go with '1'. It seems far more expected and consistent. I'm also ok with '2'. But we should still make the text clear. |
Finally, if we go with '1' or '2', i think it goes without saying that we should apply this consistently to all function-like things that can have an async-modifier. Methods/Lambdas/Anon-Methods/Local-Functions should all behave uniformly here :) |
@CyrusNajmabadi I have no problem with the spec being clarified. The spec already uses the phrase "immediately enclosing" when it means that (unlike here). |
Thanks. Sounds good to me! |
1 similar comment
Thanks. Sounds good to me! |
From the spec:
A non-async local function that is inside an async method is still "inside" of an async function, and therefore
await
should be a keyword.But the parser currently treats
await
as an ordinary identifier there.The parser appears to handle lambdas properly.
The text was updated successfully, but these errors were encountered: