-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"super" is null in static method of sub-class #41261
Comments
Same behavior on Chromium; Firefox and Safari output |
I'm fairly sure you can only extend from a return class extends this { if you only do: class A {
static foo() {
console.log(this)
}
}
A.foo() // undefined that would be the same as:
if it did work before, and does not anymore, it's likely a bug which has been fixed. |
That's precisely the bug that is being reported, the behavior of V8 is different from other JS engines. If you try your code snippet in Firefox or Safari, you get a different result – and their behavior makes more sense imo, I'd expect |
@dnalborczyk after checking in Node.js v17.x, I'm not getting class A {
static foo() {
console.log(this === undefined) // false
return this;
}
}
A.foo() // [class A] Did you see this result with a recent version of Node.js? If so, we should definitely open a bug for that!
Unrelated, but you can also extend from class A extends null {} |
no, you are absolutely right. I should not comment on any issues late a night. I broke the rule once again 😞
you are right, you can do that. I think tho the behavior is still not (well) defined. there is a longstanding issue open at TC39: tc39/ecma262#1321 if you instantiate A you get a TypeError if I remember correctly, some are arguing it should behave similar to |
doing The problem here is that |
I'm going to close this since it's v8 and there's a bug for it. |
I think we got that. the conversation just derailed a bit. |
Version
v17.2.0
Platform
Darwin MBPM.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
return class extends super.extend()
declares no new method, there is no error.We write this:
there will be no error.
What is the expected behavior?
The output should be
B.extend:A.extend:B:A
What do you see instead?
Additional information
The code works as is in older versions of Node:
![Capture d’écran 2021-12-21 à 15 37 02](https://user-images.githubusercontent.com/813661/146948327-f6148a86-170c-45cd-9a83-ffcaabf95f2b.png)
The text was updated successfully, but these errors were encountered: