Skip to content

Compiler error when calling super from a method named with a reserved word #2949

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

Closed
russelldavis opened this issue Apr 22, 2013 · 5 comments · Fixed by #3237
Closed

Compiler error when calling super from a method named with a reserved word #2949

russelldavis opened this issue Apr 22, 2013 · 5 comments · Fixed by #3237
Labels

Comments

@russelldavis
Copy link

Example:

class Child extends Parent
    @static: -> super

Note that these both compile fine:

class Child extends Parent
    @foo: -> super
class Child extends Parent
    @static: -> foo
@vendethiel
Copy link
Collaborator

Seems to come from Literal::compileNode() wrapping. Will look when I get home :).

@jashkenas
Copy link
Owner

Nice catch.

@vendethiel
Copy link
Collaborator

Looks like we don't have the { expression: { value: '_Class' } } (last expr) in Block.compileNode. Am looking further ...

EDIT : nop, looked for almost 2hours, nothing comes to my mind :p.

@jashkenas
Copy link
Owner

This seems to have been fixed. It's an error outside of an instance method, and gets quoted properly when used in one.

@russelldavis
Copy link
Author

The "Cannot call super outside of an instance method" error only gets generated when the method is named with a reserved word (just re-verified using "Try Coffeescript" at coffeescript.org). Please reopen.

@vendethiel vendethiel reopened this Oct 21, 2013
marchaefner pushed a commit to marchaefner/coffee-script that referenced this issue Nov 12, 2013
  * Fixes jashkenas#2949: Detect reserved names (not only for instance methods)
  * Don't assign names which might result in incorrect `super` calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants