Skip to content

swc minify bug #10178

@littleprincewdk

Description

@littleprincewdk

Describe the bug

swc does not recognize the change in the array in some situation.

Input code

var c = 'push'; // maybe any word

for (var a = 1, b = []; a < 5; a++) {
  b[c]({});
}

b[0][d] = 1;
b[e][f] = b[1][g];

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": true
    },
    "target": "es5",
    "loose": false,
    "minify": {
      "compress": {
        
      },
      "mangle": false
    },
    "externalHelpers": false
  },
  "module": {
    "type": "es6"
  },
  "minify": true,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.11.8&code=H4sIAAAAAAAAAxWLsQqDQBAF%2B%2F2K16koqEWqjV%2BybHF7p6ZJDCcaRPz3rNUwMLOHjIgBxXdbXwWjbfEOh40InwO%2FJSeiackod%2B%2BCd30Dc4iy6xMPR11XOAkwiVqeV8V0EZl0Kknvg11GlekWk15lVv4D3BuDjHcAAAA%3D&config=H4sIAAAAAAAAA1WPPQ7DMAiF957CYu7aDj1Blx4CuaRy5D8BkRJFuXsdx0nTDT7e48F8MQZ6sfAwcylLk5GF%2BOgLkSkqjoUA2YBi2WWF6z7tZR0pD1TJsg1AkT%2Bk1SS3pgafklBhHXqhxoKLrpvOeTaFzCRyYsa0YjlyA8aPP5b9ZdOoxBH9k3wmlpOmKiCk91Ct7WWdMm2X3uEn2u9aX6vEyWs31neXL%2B8BHY89AQAA

SWC Info output

No response

Expected behavior

terser is ok:

Image

Actual behavior

swc does not recognize the change in the array:

Image

Version

1.11.8

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions