Skip to content
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

fix await and yield for do expression #10072

Merged

Conversation

tanhauhau
Copy link
Member

Q                       A
Fixed Issues? Fixes #3780
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@babel-bot
Copy link
Collaborator

babel-bot commented Jun 9, 2019

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10961/

@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10918/

* Check whether the current path contains an `await` expression
*/

export function containsAwaitExpression(): boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can/should use hasType instead:

const hasAsync = traverse.hasType(
fn.body,
"AwaitExpression",
t.FUNCTION_TYPES,
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclaimer: I didn't know about that method until 5 mins ago. Usually, when someone adds a new method to @babel/traverse there is a 50% probability that it already exists.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to look for it too... But I guess you can find things better than me

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Do Expressions labels Jun 13, 2019
@nicolo-ribaudo
Copy link
Member

Can you disable the failing test on node 6, since it doesn't support async functions?

Example:

@nicolo-ribaudo
Copy link
Member

Sorry for the bad example, the min node version should be 8 😅

@tanhauhau
Copy link
Member Author

Oh wait what was I thinking.. haha

@tanhauhau tanhauhau changed the title fix await for do expression fix await and yield for do expression Jun 16, 2019
@tanhauhau
Copy link
Member Author

@nicolo-ribaudo I'm thinking might as well fix for yield generators as well

@nicolo-ribaudo
Copy link
Member

I'd prefer it do be done in a separate PR, since there are many more edge cases (e.g. manually calling .throw or .return, and how try/finally with nested do expression behave).

@tanhauhau tanhauhau force-pushed the tanhauhau/do-expression-async branch from 98c0957 to dcaba6a Compare June 16, 2019 14:58
@tanhauhau
Copy link
Member Author

tanhauhau commented Jun 16, 2019

@nicolo-ribaudo fixed the PR

@existentialism existentialism merged commit d50e78d into babel:master Jul 3, 2019
@tanhauhau tanhauhau deleted the tanhauhau/do-expression-async branch July 3, 2019 15:03
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Do Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Async functions with do expressions: inconsistent behavior (T6716)
4 participants