Bound instance method `super` calls run in the context of the class #2331

brian-c opened this Issue May 15, 2012 · 6 comments


None yet

5 participants

brian-c commented May 15, 2012

Noticed this in 1.3.2:

class Foo extends Bar
  hello: ->
  world: =>

f = new Foo()

hello's super runs in the context of f, but world's super runs in the context of Foo.

benjie commented May 15, 2012

I just found this issue also. It is a definite regression - here's another test case:

class A
  v: 1
  m: ->
    return @v

class B extends A
  m: =>
    @v = 2

result = new B().m()
if result isnt 2
  throw "result (#{result}) isnt 2"
  console.log "Fine"

Passes with CoffeeScript 1.2.0, but fails with 1.3.2

benjie commented May 15, 2012

I've just done a quick git bisect using a slightly modified version of the script above and that suggests the first bad commit was 5542e00 (details)


Paging @maxtaco. This would be a serious regression that would require (another) point release. I find it hard to believe that we didn't have a test case for bound functions...

nikgraf commented May 15, 2012

I just notice the same issue since we updated from 1.3.1 to 1.3.2 today.


@jashkenas Unfortunately, there's not. We have a lot of tests for super, but none are in instance-bound methods. We probably need to fix this one fast. People are going to run into it.

edit: For anyone interested, these are the relevant commits.

@jashkenas jashkenas closed this in e3454ed May 15, 2012
brian-c commented May 15, 2012

You guys are awesome. Thanks.

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