Describe the bug
When SWC lowers
myLabel: for await (const i of stream) {
continue myLabel;
}
myLabel: myLabel2: for await (const i of stream) {
break myLabel2;
}
to ES5, JS labels are lost in the output. When the output is executed, a SyntaxError gets thrown. This breaks continue or break in the body.
Input code
async function nestedLabels(stream) {
const visited = [];
outer: second: for await (const item of stream) {
if (item === 1) continue outer;
if (item === 2) break second;
visited.push(item);
}
return visited;
}
Config
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es5",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}
Link to the code that reproduces this issue
https://play.swc.rs/?version=1.16.2&code=H4sIAAAAAAAAA2WOTQrCMBCF9z3FWzYbQZctuYE3EBdpO8GgnUhmooj07qY%2FguBiNu99fG%2BcvLiHz9xriAwmURqOrqOb1KKJ3GjwroA%2BsigeQULpYXE6tyWNWSk1ECr10MDHBPd0QVGvfIFHRI9fExA86qWx1mJvZrcGzrTq2n%2FmYNAVwXUbWontl909y2VBzZxP5RJpTvwF2mr6AIOYveDlAAAA&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BAWdSIifrKJVBTl7iUE0maH3xsz8jooBbNoeKq1PMsQkYX4nEsi2Sf8lARIOxTNJia49XaWvRrRCtVoOxpIyBOluiX3hoMNQajjLXPGmzH%2FC3VwkUnkCu4o%2BsnSVTc0JbjwXmrZDkk50qF%2FwA%2FqsvNjMPLqm4kXGrYvhlQioBQBAAA%3D
SWC Info output
No response
Expected behavior
- JS labels are kept
- No runtime error, code semantics hold
Actual behavior
- JS labels are lost
- Runtime SyntaxError
Version
1.16.2
Additional context
No response
Describe the bug
When SWC lowers
to ES5, JS labels are lost in the output. When the output is executed, a SyntaxError gets thrown. This breaks
continueorbreakin the body.Input code
Config
{ "jsc": { "parser": { "syntax": "ecmascript", "jsx": false }, "target": "es5", "loose": false, "minify": { "compress": false, "mangle": false } }, "module": { "type": "es6" }, "minify": false, "isModule": true }Link to the code that reproduces this issue
https://play.swc.rs/?version=1.16.2&code=H4sIAAAAAAAAA2WOTQrCMBCF9z3FWzYbQZctuYE3EBdpO8GgnUhmooj07qY%2FguBiNu99fG%2BcvLiHz9xriAwmURqOrqOb1KKJ3GjwroA%2BsigeQULpYXE6tyWNWSk1ECr10MDHBPd0QVGvfIFHRI9fExA86qWx1mJvZrcGzrTq2n%2FmYNAVwXUbWontl909y2VBzZxP5RJpTvwF2mr6AIOYveDlAAAA&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BAWdSIifrKJVBTl7iUE0maH3xsz8jooBbNoeKq1PMsQkYX4nEsi2Sf8lARIOxTNJia49XaWvRrRCtVoOxpIyBOluiX3hoMNQajjLXPGmzH%2FC3VwkUnkCu4o%2BsnSVTc0JbjwXmrZDkk50qF%2FwA%2FqsvNjMPLqm4kXGrYvhlQioBQBAAA%3D
SWC Info output
No response
Expected behavior
Actual behavior
Version
1.16.2
Additional context
No response