Skip to content

[Bug]: Deleting this during static field initialization in strict mode results in SyntaxError #15128

@p51lee

Description

@p51lee

💻

  • Would you like to work on a fix?

How are you using Babel?

Other (Next.js, Gatsby, vue-cli, ...)

Input code

// input.js
"use strict";
class x { static y = delete this ; }

Configuration file name

No response

Configuration

No response

Current and expected behavior

Hello,

input.js terminates without error but output.js throws SyntaxError:

$ node input.js
// terminates without error
$ node output.js
output.js:10
_defineProperty(x, "y", delete x);
                               ^

SyntaxError: Delete of an unqualified identifier in strict mode.
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1088:15)
    at Module._compile (node:internal/modules/cjs/loader:1123:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.11.0

Environment

Reproduction on Babel's own REPL

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions