This repository has been archived by the owner on May 19, 2018. It is now read-only.
[WIP] Improve error message for await-outside-async #125
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.
This is an attempt to implement #113. I would love some early feedback/pointers, as well as help completing the following list which reflects the current state of this branch. I only added tests for true positives and true negatives, so they should all pass despite the work being incomplete.
Examples
馃槑 True positives 馃憤
The following all raise
await can only be used in async functions
correctly (to my understanding).await promise
return await promise
var x = await promise
x[await promise]
x(await promise)
x(await promise, 0)
await await
await yield
await this
await super
await {}
function* a() {yield await 0}
await new Promise
await.0
Non-examples
馃槑 True negatives 馃憥
The following all raise
Unexpected token
etc, correctly (to my understanding).await}
await(
- parseExprSubscriptsawait.
await[
await+
await/
await*
await[0;
await(0
await instanceof
馃槥 False positives 馃憤
The following all raise
await can only be used in async functions
incorrectly (only in actual non-async contexts, though).parseExpressionStatement
await var
await)
await~
await{
await x(
await x((
parseSubscripts
x[await
parseParenAndDistinguishExpression
(await
馃槥 False negatives 馃憥
Cases which should raise
await can only be used in async functions
but raise some other error: None that I know of.馃槑 No error at all 馃憣