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

break inside a try block does not work correctly #46

Closed
redneb opened this issue Oct 20, 2019 · 1 comment
Closed

break inside a try block does not work correctly #46

redneb opened this issue Oct 20, 2019 · 1 comment
Assignees

Comments

@redneb
Copy link

redneb commented Oct 20, 2019

Consider the following snippet where we are breaking out of loop from inside a try block:

async function foo() {
	while (true) {
		try {
			await null; // important
			console.log(1);
			break;
		}
		catch {}
		console.log(2);
	}
}

foo();

The second console.log should never run because we exit the while loop prior to that. But using babel-plugin-transform-async-to-promises and running the output of babel, it executes both console.log statements and then exits the loop:

$ ./node_modules/.bin/babel test.js | node
1
2

Contrast that to:

$ node test.js 
1
@rpetrich rpetrich self-assigned this Oct 21, 2019
rpetrich added a commit that referenced this issue Oct 26, 2019
@rpetrich
Copy link
Owner

Thanks for the test case. This is now in resolved in 0.8.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants