-
Notifications
You must be signed in to change notification settings - Fork 57
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
class extends null
is broken by ECMAScript
#98
Comments
if i read the spec (I am not sure if I read the wrong part) it looks like its is possible Do I read those wrong? |
though i dont get it work anywhere neither, here chrome (canary) console > class A extends null {}
undefined
> new A
VM79:1 Uncaught TypeError: Super constructor null of A is not a constructor
at new A (<anonymous>:1:1)
at <anonymous>:1:1 and node repl > class A extends null {}
undefined
> new A
Uncaught TypeError: Super constructor null of A is not a constructor
at new A (repl:1:1) |
yeah the only useful thing to learn is what you described. But not really of any practical value, is it? So I would rather change this test to verify that a parent must be callable with it('a class extending `null` can not be instantiated, since calling `super()` on null fails', () => {
class NullClass extends null {}
assert.throws(() => new NullClass);
}); like this |
I'm not really sure. Wouldn't that be kind of misleading new developers to assume that a We should either remove the whole test or explain the rationale behind the use-case. And also somehow probably document somewhere ( in the test itself ) that this is a gray-area test.
No, what you're reading is correct. The spec was first made to extend null, but then apparently many bad things happened and they reverted it ( see links in issue description ) I found this question on StackOverflow that questions this use-case altogether. The question has different errors of this use-case not working PS : the issue title is probably misleading, what I meant was that it was broken by ECMAScript and that it wasn't our fault. |
class extends null
is unsupported by ECMAScriptclass extends null
is broken by ECMAScript
i agree, either 1) remove the test or 2) make it more explicit, maybe like that: it('`extends null` is not supported', () => {
class NullClass extends null {}
assert.throws(() => new NullClass);
}); just to mention the edge case and its solution. |
actually, it is supported by the spec, it's just not working as intended. So, maybe, the test should be |
the MDN revision used the term 'not allowed', so, I guess 'not supported' is close enough. I'd favor 'not allowed' though. |
class extends null
was reverted by ECMAScript in tc39/ecma262#781 ( tc39/ecma262@c57ef95 ) and is still broken.The kata is abnormal since it doesn't have a solution in the test itself.
So, the question is whether we should have that test for
class extends null
?However, I found a possible solution thanks to devdocs.io ( which had a previous version of the MDN Web Docs; revision ) :
The text was updated successfully, but these errors were encountered: