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: Compile re-declare var in init and body of for await #15103

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -54,11 +54,13 @@ export default declare(api => {
// add the value declaration to the new loop body
if (declar) {
block.body.push(declar);
if (path.node.body.body.length) {
block.body.push(t.blockStatement(path.node.body.body));
}
} else {
block.body.push(...path.node.body.body);
}

// push the rest of the original loop body onto our new body
block.body.push(...path.node.body.body);

t.inherits(loop, node);
t.inherits(loop.body, node.body);

Expand Down
Expand Up @@ -5,7 +5,9 @@
try {
for (var _iterator = babelHelpers.asyncIterator(y), _step; _iteratorAbruptCompletion = !(_step = yield _iterator.next()).done; _iteratorAbruptCompletion = false) {
let x = _step.value;
f(x);
{
f(x);
}
}
} catch (err) {
_didIteratorError = true;
Expand Down
Expand Up @@ -9,7 +9,9 @@ function _f() {
try {
for (var _iterator = babelHelpers.asyncIterator(y), _step; _iteratorAbruptCompletion = !(_step = yield _iterator.next()).done; _iteratorAbruptCompletion = false) {
let x = _step.value;
g(x);
{
g(x);
}
}
} catch (err) {
_didIteratorError = true;
Expand Down
Expand Up @@ -9,7 +9,9 @@ function _g() {
try {
for (var _iterator = babelHelpers.asyncIterator(y), _step; _iteratorAbruptCompletion = !(_step = yield babelHelpers.awaitAsyncGenerator(_iterator.next())).done; _iteratorAbruptCompletion = false) {
let x = _step.value;
f(x);
{
f(x);
}
}
} catch (err) {
_didIteratorError = true;
Expand Down
Expand Up @@ -9,9 +9,11 @@ function _fn() {
try {
for (var _iterator = babelHelpers.asyncIterator([Promise.resolve("ok")]), _step; _iteratorAbruptCompletion = !(_step = yield babelHelpers.awaitAsyncGenerator(_iterator.next())).done; _iteratorAbruptCompletion = false) {
const result = _step.value;
return {
result
};
{
return {
result
};
}
}
} catch (err) {
_didIteratorError = true;
Expand Down
Expand Up @@ -12,7 +12,9 @@ function _f() {
x,
y: [z]
} = _step.value;
g(x, z);
{
g(x, z);
}
}
} catch (err) {
_didIteratorError = true;
Expand Down
@@ -0,0 +1,3 @@
( async () => {
for await ( let x of [ ] ) { let x; }
} ) ;
@@ -0,0 +1,3 @@
( async () => {
for await ( let x of [ ] ) { let x; }
} ) ;
@@ -0,0 +1,26 @@
/*#__PURE__*/babelHelpers.asyncToGenerator(function* () {
var _iteratorAbruptCompletion = false;
var _didIteratorError = false;
var _iteratorError;
try {
for (var _iterator = babelHelpers.asyncIterator([]), _step; _iteratorAbruptCompletion = !(_step = yield _iterator.next()).done; _iteratorAbruptCompletion = false) {
let x = _step.value;
{
let x;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (_iteratorAbruptCompletion && _iterator.return != null) {
yield _iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
});