-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix #4752: Error on calling super with @params in a derived class constructor #4754
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
Fix #4752: Error on calling super with @params in a derived class constructor #4754
Conversation
…class constructor
Anyone familiar with the codebase available to review this? @vendethiel? @xixixao? This one's only two lines plus a test. |
This won't catch code like |
It looks like |
I meant specifically using |
That’s the issue: we’re generating valid JavaScript, that just happens not to correspond to the user’s intent. See: class extends parent
constructor: (@arg) ->
super(=> @arg) (class extends parent {
constructor(arg) {
super(() => {
return this.arg;
});
this.arg = arg;
}
}); Babel allows this, but it’s not the user’s intent because |
Okay @vendethiel, I’ve found a way to search the tree of nodes that make up |
This goes a bit too deep: coffee -bcs
class extends A then constructor: (@a) -> super(class then constructor: (@b) -> @b)
[stdin]:1:74: error: Can't call super with @params in derived class constructors
class extends A then constructor: (@a) -> super(class then constructor: (@b) -> @b) |
I tried using I think the same could be said for this case. Would you agree? |
|
Thanks. I guess let's leave this open another day to see if anyone else has an opinion. Any other notes? |
Fixes #4752, in the sense that now we throw a compiler error rather than outputting invalid JavaScript. If we want to go further and create some placeholder variables to engage in sleight of hand to make the impossible possible, well, that can be a follow-up PR.