Skip to content

incorrect "unused pure expression or super" #16262

@trusktr

Description

@trusktr

Bug report

What is the current behavior?

Code like this,

let _Foo;

class Foo {
  static #_ = [_init_foo, _initProto, _Foo, _initClass2] = _applyDecs(this, [[signal, 3, "lorem"], [signal, 0, "foo"]], [reactive]);
  foo = (_initProto(this), _init_foo(this, 123));

  get lorem() {
    return 123;
  }

  set lorem(v) {
    v;
  }

  static #_2 = _initClass2();
}

let _Bar;

class Bar extends _Foo {
  static #_ = [_init_bar, _initProto2, _Bar, _initClass3] = _applyDecs(this, [[signal, 3, "baz"], [signal, 0, "bar"]], [reactive]);
  bar = (_initProto2(this), _init_bar(this, 456));
  #baz = 789;

  get baz() {
    return this.#baz;
  }

  set baz(v) {
    this.#baz = v;
  }

  constructor() {
    super();
    console.log('Bar');
  }

  static #_2 = _initClass3();
}

turns into code like this,

let _Foo;

class Foo {
  static #_ = [_init_foo, _initProto, _Foo, _initClass2] = _applyDecs(this, [[signal, 3, "lorem"], [signal, 0, "foo"]], [reactive]);
  foo = (_initProto(this), _init_foo(this, 123));

  get lorem() {
    return 123;
  }

  set lorem(v) {
    v;
  }

  static #_2 = _initClass2();
}

let _Bar;

class Bar extends (/* unused pure expression or super */ null && (_Foo)) {
  static #_ = [_init_bar, _initProto2, _Bar, _initClass3] = _applyDecs(this, [[signal, 3, "baz"], [signal, 0, "bar"]], [reactive]);
  bar = (_initProto2(this), _init_bar(this, 456));
  #baz = 789;

  get baz() {
    return this.#baz;
  }

  set baz(v) {
    this.#baz = v;
  }

  constructor() {
    super();
    console.log('Bar');
  }

  static #_2 = _initClass3();
}

and the class fails to run because super() tries to call null.

The input is output from Babel's new Stage 3 decorators. The static #_ initializer runs code that sets up the _Foo variable.

If the current behavior is a bug, please provide the steps to reproduce.

I haven't published a reproduction yet.

What is the expected behavior?

Other relevant information:
webpack: 5.74.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Shipped

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions