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 in class extending null should disallow super call in constructor #698

Closed
bterlson opened this Issue Sep 28, 2016 · 7 comments

Comments

Projects
None yet
3 participants
@bterlson
Member

bterlson commented Sep 28, 2016

It presently keys off of ClassHeritage being present but if it's present but null it should also be an early error. /cc @bmeck

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Sep 28, 2016

Member

I'm also not entirely sure why we didn't make super in base class methods an early error (rather than a TypeError by way of MakeSuperPropertyReference). @allenwb thoughts?

Member

bterlson commented Sep 28, 2016

I'm also not entirely sure why we didn't make super in base class methods an early error (rather than a TypeError by way of MakeSuperPropertyReference). @allenwb thoughts?

@bakkot

This comment has been minimized.

Show comment
Hide comment
@bakkot

bakkot Sep 28, 2016

Contributor

@bterlson, given that it works in object literals, it would be at least a little surprising if didn't work in base classes.

e.g.

''+(new class {
  toString(){
    return 'my ' + super.toString();
  }
}); // "my [object Object]"
Contributor

bakkot commented Sep 28, 2016

@bterlson, given that it works in object literals, it would be at least a little surprising if didn't work in base classes.

e.g.

''+(new class {
  toString(){
    return 'my ' + super.toString();
  }
}); // "my [object Object]"
@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Sep 28, 2016

Member

@bakkot right, thanks!

So presumably we could make super in methods for class extends null an early error?

Member

bterlson commented Sep 28, 2016

@bakkot right, thanks!

So presumably we could make super in methods for class extends null an early error?

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Sep 28, 2016

Member

@ajklein points out that [[HomeObject]]'s prototype is determined dynamically, so the prototype could change.

Member

bterlson commented Sep 28, 2016

@ajklein points out that [[HomeObject]]'s prototype is determined dynamically, so the prototype could change.

@bakkot

This comment has been minimized.

Show comment
Hide comment
@bakkot

bakkot Sep 28, 2016

Contributor

Are we talking about the literal null, vs e.g. class extends (()=>null)() {}? Because as I understood it ClassHeritage could evaluate to null at runtime - but we can't have early errors for that.

Contributor

bakkot commented Sep 28, 2016

Are we talking about the literal null, vs e.g. class extends (()=>null)() {}? Because as I understood it ClassHeritage could evaluate to null at runtime - but we can't have early errors for that.

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Sep 28, 2016

Member

Thanks to @ajklein my understanding is now that if [[HomeObject]] ever became changeable, which was previously possible, that extends X could always change from null to non-null, so super access can't be an early error.

Member

ljharb commented Sep 28, 2016

Thanks to @ajklein my understanding is now that if [[HomeObject]] ever became changeable, which was previously possible, that extends X could always change from null to non-null, so super access can't be an early error.

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Sep 28, 2016

Member

@bakkot yeah you're right, early error is only possible with the null literal (unless we throw early-ish during CDE, but I wouldn't argue for that I guess).

Member

bterlson commented Sep 28, 2016

@bakkot yeah you're right, early error is only possible with the null literal (unless we throw early-ish during CDE, but I wouldn't argue for that I guess).

@bterlson bterlson closed this Sep 28, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment