Bug 155060
| Summary: | Second call to super() should fail | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Ryosuke Niwa <rniwa> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | Normal | CC: | ggaren, gskachkov, keith_miller, saam, ysuzuki |
| Priority: | P2 | ||
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Ryosuke Niwa
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.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
GSkachkov
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.
Ryosuke Niwa
Does your patch for the bug 151113 also fix this bug? Or do we still need to keep this bug around?
GSkachkov
(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.
Ryosuke Niwa
Let's dupe this bug in that case.
*** This bug has been marked as a duplicate of bug 151113 ***