Skip to content

minifier: var __proto__ = []; console.log({ __proto__ }) is wrongly compressed to console.log({ __proto__: [] }) #11105

@sapphi-red

Description

@sapphi-red

Describe the bug

var __proto__ = []; console.log({ __proto__ }) is wrongly compressed to console.log({ __proto__: [] }).
This changes the behavior.

var __proto__ = []; console.log({ __proto__ } instanceof Array) // false
console.log({ __proto__: [] } instanceof Array); // true

Input code

var __proto__ = []; console.log({ __proto__ })

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "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
      }
    },
    "externalHelpers": false,
    "target": "es2024",
    "preserveAllComments": true
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true,
}

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.13.5&code=H4sIAAAAAAAAAytLLFKIjy8oyi%2FJj49XsFWIjrVWSM7PK87PSdXLyU%2FXqEaSrdUEALxe7dkuAAAA&config=H4sIAAAAAAAAA32VS2%2FbMAyA7%2FsVgc47DMXQw27FgGGX%2FQZBsShHmSwaIpXGKPLfS7%2FStKFzi%2FnxIT7z9m23M0dqzK%2Fdm%2FyUj94VgnL9FgkNmd1ZJAaazlFTYs%2Fm%2B0qPNKLgEsEkuszEJESClSyyLuYYhlvfDXZ9AaIbmUhdaWsHmemz%2FcIKvo6AS72V7xETuPyAWEc2ZoYWiua4wZRcT2BPrihexpe6Egm1ECOsDN72BXuVZx85YpaY99SD87ZBDwqKBRqOJ9DMJJaYZZL0lHwm7GFf23bq5xdrOLlUHSsx4Ty1RF6reD1gJLahZq2EM9yowQyX4n61jMEW4Fryvd0RY97oyX8AqUByRNl1oPmdNILM05Z1eGgZc5CR5UHhMt9alhlaKaqNMSiVHSsDhaPWzQK%2BNjBWttGes%2BCN8lH0YCEEmRXFNb1Gbg5aUB56wKAA6a8L2lTNwF63cIOPC%2FEA%2F5EsWR%2BwRaNzfNimNHR7TA8CdMAH9A8UpBWM27jIlTj327xmDzIa4FWVShO4PwKyAIw2AWuzIeshHm2bcP9xJhaFy6fbCmeGIrfkL6T%2B7pgZlnGfIhigpx9PP5dbbcathnKCl5R%2BY7fe1yXI5Np06Ot0TJY%2Fg3E%2BZkfP5kNpveLXoCbSv9VyTuvyDqeLwExZBgAA

SWC Info output

No response

Expected behavior

The behavior to not change. For example, output console.log({ ['__proto__']: [] }).

Actual behavior

The behavior changes.

Version

1.13.5

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