mirror of
https://github.com/swc-project/swc.git
synced 2024-10-04 20:28:43 +03:00
fix(es/compat): Visit children of while
statement in the generator
pass (#7624)
**Related issue:** - Closes #7622.
This commit is contained in:
parent
2e7b05e588
commit
d2ac2c16a3
19
crates/swc/tests/fixture/issues-7xxx/7622/input/.swcrc
Normal file
19
crates/swc/tests/fixture/issues-7xxx/7622/input/.swcrc
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"tsx": false
|
||||
},
|
||||
"target": "es5",
|
||||
"loose": false,
|
||||
"minify": {
|
||||
"compress": false,
|
||||
"mangle": false
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "es6"
|
||||
},
|
||||
"minify": false,
|
||||
"isModule": true
|
||||
}
|
11
crates/swc/tests/fixture/issues-7xxx/7622/input/1.js
Normal file
11
crates/swc/tests/fixture/issues-7xxx/7622/input/1.js
Normal file
@ -0,0 +1,11 @@
|
||||
async function asyncWhile() {
|
||||
while (true) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function* generatorWhile() {
|
||||
while (true) {
|
||||
return {};
|
||||
}
|
||||
}
|
34
crates/swc/tests/fixture/issues-7xxx/7622/output/1.js
Normal file
34
crates/swc/tests/fixture/issues-7xxx/7622/output/1.js
Normal file
@ -0,0 +1,34 @@
|
||||
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
||||
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
||||
function asyncWhile() {
|
||||
return _asyncWhile.apply(this, arguments);
|
||||
}
|
||||
function _asyncWhile() {
|
||||
_asyncWhile = _async_to_generator(function() {
|
||||
return _ts_generator(this, function(_state) {
|
||||
while(true){
|
||||
return [
|
||||
2,
|
||||
{}
|
||||
];
|
||||
}
|
||||
return [
|
||||
2
|
||||
];
|
||||
});
|
||||
});
|
||||
return _asyncWhile.apply(this, arguments);
|
||||
}
|
||||
function generatorWhile() {
|
||||
return _ts_generator(this, function(_state) {
|
||||
while(true){
|
||||
return [
|
||||
2,
|
||||
{}
|
||||
];
|
||||
}
|
||||
return [
|
||||
2
|
||||
];
|
||||
});
|
||||
}
|
@ -1646,6 +1646,8 @@ impl Generator {
|
||||
self.emit_break(loop_label, None);
|
||||
self.end_loop_block();
|
||||
} else {
|
||||
node.visit_mut_children_with(self);
|
||||
|
||||
self.emit_stmt(Stmt::While(node));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user