for...of transformation mess up repeated JS labels
Author: XinkaiCreated Sep 28, 2026Updated Sep 28, 2026
LabelsC-bug
Describe the bug
swc does not treat repeated consecutive JS labels exactly correctly when applied for...of transform.
Note: There may not be a real difference if people use swc as binary. However, the discrimination of these JS labels creates a problem for me when I am using swc as a framework and swc passes as components.
Input code
async function nestedLabels(arr) {
first:
second:
third:
for (const item of arr) {
if (true) continue first;
if (true) break first;
if (true) continue second;
if (true) break second;
if (true) continue third;
if (true) break third;
}
}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
SWC Info output
No response
Expected behavior
Three labels first, second, third should be on the same (inner) side of try {
Actual behavior
first, second are outside try and third is inside try.
Version
1.16.2
Additional context
No response
Source: swc-project/swc