-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(es/compat): Fix finally
handling of generator
#7215
Conversation
Expected output: "use strict";
function generator() {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, , 4, 6]);
_a.label = 1;
case 1:
if (!true) return [3 /*break*/, 3];
return [4 /*yield*/, "foo"];
case 2:
_a.sent();
return [3 /*break*/, 1];
case 3: return [3 /*break*/, 6];
case 4: return [4 /*yield*/, "bar"];
case 5:
_a.sent();
return [7 /*endfinally*/];
case 6: return [2 /*return*/];
}
});
}
function test() {
var gen = generator();
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next().value);
}
test(); Output of swc: function generator() {
return __generator(this, function(_state) {
switch(_state.label){
case 0:
_state.trys.push([
0,
,
3,
5
]);
if (!true) return [
3,
2
];
return [
4,
"foo"
];
case 1:
_state.sent();
return [
3,
0
];
case 2:
return [
3,
5
];
case 3:
return [
4,
"bar"
];
case 4:
_state.sent();
return [
7
];
case 5:
return [
2
];
}
});
} |
Investigation:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swc-bump:
- swc_ecma_transforms_compat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated review comment generated by auto-rebase script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated review comment generated by auto-rebase script
Description:
Update generator implementation to match https://github.com/microsoft/TypeScript/blob/e83d61398ea0e4231e882121dd6c6bcfe4fdc9e4/src/compiler/transformers/generators.ts
Related issue: