Skip to content

Super calls on computed properties crash the compiler #1184

Closed
@ochafik

Description

@ochafik

Offending code:

class Foo {
  ['m']() { return 1; }
}
class Bar extends Foo {
  ['m']() {
    return super['m']() + 1;
  }
}
console.log(new Bar()['m']());

Produces the following error with --language_in=ES6 --language_out=ES5 -O SIMPLE:

java.lang.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(SUPER): /usr/local/google/home/ochafik/super.js:19:11
    return super['M']() + 1;
  Parent(GETELEM): /usr/local/google/home/ochafik/super.js:19:11
    return super['M']() + 1;

    at com.google.javascript.jscomp.Es6ConvertSuper.visitSuper(Es6ConvertSuper.java:135)
    at com.google.javascript.jscomp.Es6ConvertSuper.visit(Es6ConvertSuper.java:70)
    at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:609)

Note that the following compiles fine since #1125:

class Foo {
  m() { return 1; }
}
class Bar extends Foo {
  m() {
    return super.m() + 1;
  }
}
console.log(new Bar().m());

(happens with output from DDC, where we sometimes use Symbols in conjunction with computed props).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions