Bug 155060 - Second call to super() should fail
Summary: Second call to super() should fail
Status: RESOLVED DUPLICATE of bug 151113
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-04 20:07 PST by Ryosuke Niwa
Modified: 2016-04-11 00:02 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2016-03-04 20:07:18 PST
class A { }
class B extends A { constructor() { super(); console.log('hi'); super(); } }

should fail immediately after 'hi' since "this" is already created.

Specifically, step 10 in SuperCall:
http://www.ecma-international.org/ecma-262/6.0/#sec-super-keyword-runtime-semantics-evaluation

10. Return thisER.BindThisValue(result).

should throw a ReferenceError because of step 3:
http://www.ecma-international.org/ecma-262/6.0/#sec-bindthisvalue

3. If envRec.[[thisBindingStatus]] is "initialized", throw a ReferenceError exception.
Comment 1 GSkachkov 2016-03-04 23:16:10 PST
We have very close issue to this https://bugs.webkit.org/show_bug.cgi?id=151113 that rely on discussion https://esdiscuss.org/topic/duplicate-super-call-behaviour
test example:
class Foo {
  constructor() {
    console.log("foo");
  }
}

class Bar extends Foo {
  constructor() {
    super();
    console.log("bar");
    super();
  }
}

new Bar;

If we will strictly follow specs we will have:
foo
bar 
foo
ReferenceError: This can not be initialized twice.
Comment 2 Ryosuke Niwa 2016-04-10 23:59:01 PDT
Does your patch for the bug 151113 also fix this bug?  Or do we still need to keep this bug around?
Comment 3 GSkachkov 2016-04-11 00:01:47 PDT
(In reply to comment #2)
> Does your patch for the bug 151113 also fix this bug?  Or do we still need
> to keep this bug around?

Yes, I think it is the same issue, so path for 151113 fix this issue.
Comment 4 Ryosuke Niwa 2016-04-11 00:02:21 PDT
Let's dupe this bug in that case.

*** This bug has been marked as a duplicate of bug 151113 ***