google / google/closure-compiler
References to this in parameter passed to super should error.
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
The following code will throw an exception in Chrome, as `this` isn't defined until super is called:
```js
class A {
constructor(x) {}
}
class B extends A {
constructor() { super(this); }
}
new B();
```
However, it compiles without errors or warnings.
https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520SIMPLE_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F%252F%2520ADD%2520YOUR%2520CODE%2520HERE%250A%250Aclass%2520A%2520%257B%250A%2520%2520constructor(x)%2520%257B%257D%250A%257D%250A%250Aclass%2520B%2520extends%2520A%2520%257B%250A%2520%2520constructor()%2520%257Bsuper(this)%253B%257D%250A%257D%250A%250Anew%2520B()%253B%250A
Contributor guide
Assessment
This issue has not been assessed yet.