-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Incorrect yield and try-finally behaviour #5913
Comments
This was referenced Apr 5, 2023
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*/];
}
});
}
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
];
}
});
} |
kdy1
added a commit
that referenced
this issue
Apr 6, 2023
**Description:** Update generator implementation to match https://github.com/microsoft/TypeScript/blob/e83d61398ea0e4231e882121dd6c6bcfe4fdc9e4/src/compiler/transformers/generators.ts **Related issue:** - Closes #5913.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
I'm using Next.js with SWC and redux-saga and noticed that updating Next.js from 12.2.1 to 12.3.1 broke redux-saga for me.
Turns out wrapping a yield statement in a try-finally block doesn't behave as it should with SWC.
Input code
Config
Copied from playground defaults:
Playground link
https://play.swc.rs/?version=1.3.2&code=H4sIAAAAAAAAA72PwQ2DMAxF70zxxSn0wAIR3SWlhkayYimYtqjK7gQaUSboxbb8v%2B1nYxp0V3wqYJhDr17CBSMFik4lZnFTAI1LqYDXwzPBaJypOZrA4onvqAeR2pZm2nPC4INj%2Fm0o1puLxboZU3VigNKkx%2FVewqQbFbozmz1EYWpZRpPFNtA7T7ZPx5nvr5b9gy%2B4rVKT4wq0x%2FTnXgEAAA%3D%3D&config=H4sIAAAAAAAAA0WNSwrDMAxE76J1ts0id%2BghjKsEF%2F%2FQKBBjfPfawSU7aebpqdIXlrZK2QhYxoQS1Vy0kZbMsOKy0kKKHu3Gg1tfjBysHWG8eudTAs92oeCi28sw2RSyMPBUJh7%2BT7YuCulzjqDez27hSu1xzDuH9wRVTm4%2FOkwQUrUAAAA%3D
Expected behavior
Running the input code from the playground outputs
Actual behavior
Running the output code from the playground outputs
Version
1.3.2
Additional context
No response
The text was updated successfully, but these errors were encountered: