Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#12433·swc

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

typescript
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

json
{
  "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=H4sIAAAAAAAAA22OsQ3DMAwEe0%2FxpbyCs0KWkGUKIZJQAEkVRuDdo9iAikDdg%2FdHMtouCblKci4CIXPa7nGll4WoOuMzAZnVfGnBKBXZfskfrGfIRRHa1Bzs9EbJ6B7AGcG10oxWcZZK17LbH12V4nOMungdH5tj1tXz27HZ0TEdX7sLgoMNAQAA&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BAWdSIifrKJVBTl7iUE0maH3xsz8jooBbNoeKq1PMsQkYX4nEsi2Sf8lARIOxTNJia49XaWvRrRCtVoOxpIyBOluiX3hoMNQajjLXPGmzH%2FC3VwkUnkCu4o%2BsnSVTc0JbjwXmrZDkk50qF%2FwA%2FqsvNjMPLqm4kXGrYvhlQioBQBAAA%3D

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

View original on GitHubView discussion on GitHub