google / google/closure-compiler

Advanced compilation breaks due to lack of __proto__ support?

Open
#570 7 comments 0 reactions 0 assignees View on GitHub
enhancement ES6 Types
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

``` js
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// @use_closure_library true
// @formatting pretty_print
// ==/ClosureCompiler==

/** @constructor */
function Base() {
}
Base.prototype.x = 1;

/** @constructor @extends {Base} */
function Derived() {
Base.call(this);
}
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived
};

var d = new Derived;
alert(d.x);
```

This compiles to:

``` js
function a() {
}
a.prototype = {};
alert((new a).x);
```

Which is clearly not right.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.