Closed bergus closed 8 years ago
Good catch, I forgot to add this. new.target
has some stuff prohibiting it at top level...
I looked in to doing this and I don't think it's generally possible. In scripts, await
is not a keyword, so this would disallow perfectly valid code.
We may be able to do this in modules...
https://github.com/domenic/cancelable-promise/commit/eb656c603ba9a71e8233899e17132c4fe6631409 prohibits at top level in modules. Still working on how to prohibit inside non-async functions inside modules.
Yes, only in strict mode code, similar to how await
is prohibited as an identifier name there (iirc).
I guess the proposal did forget to mention that await.cancelToken
only parses as a meta property in such code, and as a normal property access otherwise. For new.target
, such a definition was not yet necessary.
No, strict mode code is allowed to use await.cancelToken
as the property of an object named await
. It's only module code where await
is reserved as a keyword.
In general it seems like the spec is very borked right now though, as you pointed out. We only want to interpret this as a meta-property inside async functions...
…when used outside of
async
functions. I'd like to see some kind of static semantic rule that only allows it in places where you also can find anawait
keyword. The current draft only throws a run-timeReferenceError
when the property is used (evaluated) outside of an asynchronous execution context that has the necessary slot.