#12373·swc

PURE on destructuring assignment also marks getters as pure

Author: mischnicCreated Sep 14, 2026Updated Sep 14, 2026
LabelsC-bug

Describe the bug

This shouldn't remove the const {} bit as well, it might have side effects on the getters?

cc @lukesandberg

Input code

typescript
const {a} = /*#__PURE__*/x();
log(b);

Config

json
{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "target": "es2015",
    "loose": false,
    "minify": {
      "compress": {
        "arguments": false,
        "arrows": true,
        "booleans": true,
        "booleans_as_integers": false,
        "collapse_vars": true,
        "comparisons": true,
        "computed_props": true,
        "conditionals": true,
        "dead_code": true,
        "directives": true,
        "drop_console": false,
        "drop_debugger": true,
        "evaluate": true,
        "expression": false,
        "hoist_funs": false,
        "hoist_props": true,
        "hoist_vars": false,
        "if_return": true,
        "join_vars": true,
        "keep_classnames": false,
        "keep_fargs": true,
        "keep_fnames": false,
        "keep_infinity": false,
        "loops": true,
        "negate_iife": true,
        "properties": true,
        "reduce_funcs": false,
        "reduce_vars": false,
        "side_effects": true,
        "switches": true,
        "typeofs": true,
        "unsafe": false,
        "unsafe_arrows": false,
        "unsafe_comps": false,
        "unsafe_Function": false,
        "unsafe_math": false,
        "unsafe_symbols": false,
        "unsafe_methods": false,
        "unsafe_proto": false,
        "unsafe_regexp": false,
        "unsafe_undefined": false,
        "unused": true,
        "const_to_let": true,
        "pristine_globals": true
      },
      "mangle": {
        "toplevel": false,
        "keep_classnames": false,
        "keep_fnames": false,
        "keep_private_props": false,
        "ie8": false,
        "safari10": false
      }
    },
    "preserveAllComments": true
  },
  "module": {
    "type": "es6"
  },
  "minify": true,
  "isModule": true
}

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.16.4-nightly-20260913.1&code=H4sIAAAAAAAAA0vOzysuUahOrFWwVdDXUo6PDwgNco2P19Kv0NC05srJT9dIAtIAjLhdTCYAAAA%3D&config=H4sIAAAAAAAAA41VwW7bMAy97ysCn3doB2wYdhsG7LZvEBSLctTJoiFSboIi%2Fz7KsdOkoY3dbD4%2BUqQeqbdPu13zQm3zY%2Fcmn%2FIz2EyQr%2F9ioVNiexRLw6cBqM1h4ObzgjJVyNtIMJnOF6RhmzvgygL68vT8dWY0EZFgYcy2PqTgT7c5W%2ByHDEQ3NrFKyNJDYrrnz1jG1wpwLrf2PWIEmzYQY8mExNBB1gK3GKMdCMxosxKlntTmQKilqGBhcGbIOKh4coEDJsn5iDqwzrToQIFChpbDCBpNcgktkZSn1DPBDval66Z7%2FsCG0cZiWckJx%2BlK5LRK1AMGYuNL0lp4AVd6cAHn5n5kBm8ycMnpkfeCIa3cyV8A6UC0RMn2oMWdPLzoaY3tN5kheZEsnxRc9K1VmaCTppoQvNLZ2hnIHLTbzOBKC7WzrXacGV5pHwUHBrwXrSih6TVwe9CS1kFHrwByv9ZrqroA5jqFK3gdiA34t1TJusBmj97yYR2lU7%2FHuJGgBz6g23CQq2Bch7NsieOwjpfkQKQBTnUpNAGPS0AGgNHEaV8%2BaEPGQyKaLuL%2BfU3MDufrHu5t6qZ5v9mXjEOEEeKajP9jRDZROdtYVb1M9sP0wndNlFYGLzw%2F3T0bUsrd81FXDeQRfsb4C%2Ftl6c%2BVT05Nj67cVDyJ9vLefGvenZanZWlrE%2BjPQpzCnf8B5oY%2FuAQHAAA%3D

SWC Info output

No response

Expected behavior

javascript
const {a} = /*#__PURE__*/x();
log(b);

Actual behavior

javascript
/*#__PURE__*/log(b);

Version

1.16.4-nightly-20260913.1

Additional context

No response