New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 597493 link

Starred by 5 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Mar 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

super() does not work properly in a class extended from Object

Reported by wenchong...@gmail.com, Mar 24 2016

Issue description

Chrome Version       : 49.0.2623.87, 51.0.2683.0 
URLs (if applicable) :
Other browsers tested:
  Add OK or FAIL, along with the version, after other browsers where you
have tested this issue:
     Safari:
    Firefox:
         IE:

What steps will reproduce the problem?
(1)Open the console panel
(2)type in:
class NewObj extends Object{
  constructor(){
    super(...arguments);
  }
}
var o = new NewObj({attr: true});
console.log(o.attr === true);

(3)enter

What is the expected result?
true (according to ECMAScript 6 and Babel v6.x)

What happens instead?
false

Please provide any additional information below. Attach a screenshot if
possible.

 
Screen Shot 2016-03-23 at 8.23.32 PM.png
63.4 KB View Download
I guess you didn't read the spec correctly, this is a Babel bug, not a V8 bug.
Why would this be a Babel bug? The constructor is passing arguments via a super() call, which seems like it should work and which is certainly allowed in the spec.

Comment 3 Deleted

See 19.1.1.1-1 https://tc39.github.io/ecma262/#sec-object-value:

If NewTarget is neither undefined nor the active function, then Return ? OrdinaryCreateFromConstructor(NewTarget, "%ObjectPrototype%").

This says when Object is used as a super class, the argument `{attr: true}` would be completely ignored, instead, `Object.create(NewObj.prototype)` is returned, so `o.attr` would be undefined.

For the same reason, `Reflect.construct(Object,[{attr:true}],function subclass(){}).attr` is undefined.
Components: Blink>JavaScript
Cc: littledan@chromium.org
Status: WontFix (was: Unconfirmed)

Sign in to add a comment