Skip to content

[Bug]: new.target as a constructor #1282

Open

Description

@p51lee

Bug report

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

$ terser -V
terser 5.15.1

Complete CLI command or minify() options used
I turned off the unsafe option.

$ terser input.js -c unsafe=false

terser input

class x { static { var x = class extends new . target { } ; } } 

terser output or error

class x{static{new.target}}

Expected result
Executing the output code, TypeError is expected since input code throws TypeError.
However, output code terminates without error.

$ node -e "class x { static { var x = class extends new . target { } ; } }" // input code throws a TypeError
[eval]:1
class x { static { var x = class extends new . target { } ; } }
                           ^

TypeError: Class extends value undefined is not a constructor or null
    at <static_initializer> ([eval]:1:28)
    at [eval]:1:1
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:313:38)
    at node:internal/process/execution:79:19
    at [eval]-wrapper:6:22
    at evalScript (node:internal/process/execution:78:60)
    at node:internal/main/eval_string:28:3

Node.js v18.11.0
$ node -e "class x{static{new.target}}" // output code terminates without error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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