Skip to content

[Bug]: More Than One Super Call in the Construction is Incorrectly Allowed #14652

@clhiker

Description

@clhiker

💻

  • Would you like to work on a fix?

How are you using Babel?

@babel/cli

Input code

class envs {
    constructor(param, obj) {
        console.log(param)
    }
}
function obj2() {
    return 2;
}
function battlePlayer() {
    return 1;
}
class doSomethingMore extends envs {
    constructor() {
        super(super(), obj2());
        // super(obj2(), battlePlayer());
    }
}
b = new doSomethingMore()

It's the transpiled one
It is the report error one

Configuration file name

babel.config.json

Configuration

{
  "sourceType": "unambiguous",
  "presets": ["@babel/preset-env"],
  "plugins": [
    "@babel/plugin-transform-runtime"
  ]
}

Current and expected behavior

In the poc.js, super() in the constructor is called more than once, it is the wrong syntax, but it transpiled by babel.
However, if I add code to constructor:

super(obj2(), battlePlayer());

it can report

Container is falsy

Environment

  • babel
    • ├── @babel/cli@7.17.0=6
    • ├── @babel/generator@7.17.3
    • ├── @babel/plugin-transform-runtime@7.17.0
    • ├── @babel/preset-env@7.16.11
  • Node: [v17.3.0]
  • npm version [8.5.2]
  • os [ubuntu 20.04]

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

good first issueoutdatedA 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