Skip to content

Missing parentheses around private name in inverted "in" operator #1516

@CordonZeus22

Description

@CordonZeus22

Bug report or Feature request?

Bug report

Version (complete output of terser -V or specific git commit)

terser 5.30.1

Complete CLI command or minify() options used

terser test.js --compress --output test.min.js

terser input

class X {
    #y;

    z() {
        if(!(#y in this)) {
            return 0;
        }
    }
}

terser output or error

class X{#y;z(){if(!#y in this)return 0}}

Running the code throw this exception

class X{#y;z(){if(!#y in this)return 0}}
                   ^^

SyntaxError: Unexpected identifier '#y'
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:167:18)
    at callTranslator (node:internal/modules/esm/loader:285:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:30)
    at async link (node:internal/modules/esm/module_job:76:21)

Node.js v20.11.1

Expected result

class X{#y;z(){if(!(#y in this))return 0}}

Keeping the parentheses around #y in this solve this problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions