-
Notifications
You must be signed in to change notification settings - Fork 10
Why not allow await
?
#24
Comments
Wouldn't allowing it mean that the partially-constructed class would be observable for more than just the rest of the static block? |
How so? Code after the class wouldn't run until the |
What I mean is, the class could provide its partially-constructed class to other code, and then finish with the static block code after N ticks had passed and the class had been mutated. I'm not sure why that seems worse to me than the exact same thing happening synchronously, though, so maybe it's fine. |
This is essentially a duplicate of #7 and you can read my rationale for why this is currently disallowed there. We may need to do something more to disallow There shouldn't be a concern for |
#7 doesn't really include any rationale, that I can see. It just says it's not permitted. |
It's surprising to me that this forbids
await
. I'd expect to be able to do anything I could do in the surrounding code, including initialization of the class itself which might require waiting for some asynchronous operation.Note that you can already
await
in computed property names:is legal today.
This can't just be legalized in a followup because it interacts with parsing: if the
await
flag is not passed to the static block, thenis syntactically legal even in an async context. To keep the possibility of legalizing this open, at the very least we'd need to pass the correct grammar flag today and just make
AwaitExpression
an error. But it seems both simpler and more useful to inheritasync
-ness from the surrounding context.(Edit: I should mention that similar concerns apply to
yield
, though the parsing isn't as tricky.)The text was updated successfully, but these errors were encountered: