-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow super in methods with dynamic names #3785
Conversation
Since class A
@a = -> super is allowed, and the static method compiles to A.a = function() {
return A.__super__.constructor.a.apply(this, arguments);
}; shouldn’t A.a = -> super be allowed too, and compile to the same thing? This would allow: # class style
class A extends B
@a: -> super
a: -> super
# classic style
A = ->
A extends B
A.a = -> super # currently an error
A::a = -> super |
@@ -2296,3 +2303,10 @@ unfoldSoak = (o, parent, name) -> | |||
parent[name] = ifn.body | |||
ifn.body = new Value parent | |||
ifn | |||
|
|||
# Check if `.prop` or `["prop"]` is equal to `property`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, this comment is wrong.
I’ve fixed the bad comment now. |
My proposal above might not be a good idea, because then A['prototype'].a = -> super and prototype = 'prototype'
A[prototype].a = -> super would compile to different things, which might be confusing. An error message in the latter case might be preferable. |
Fixed merge conflict. |
I’ve removed the code to allow
In other words, nothing controversial. This should make it easier to merge, I think. |
Rebase for a clean merge, and we'll merge? |
As discussed in jashkenas#3039 (comment). This is the first step to implement dynamic object literal keys (see jashkenas#3597). This also fixes jashkenas#1392. In short, `super` is now allowed: # in class definitions: class A instanceMethod: -> super @staticmethod: -> super @staticMethod2 = -> super # in assignment where the next to last access is 'prototype': A::m = -> super A.prototype.m = -> super a.b()[5]::m = -> super A::[x()] = -> super class B @::m = -> super
Rebased. |
Merged. |
Allow super in methods with dynamic names
Bravo on killing off that nasty METHOD_DEF, by the way. |
As discussed in #3039 (comment).
This is the first step to implement dynamic object literal keys (see #3597).
This also fixes #1392.
In short,
super
is now allowed: