Fix 5085 (#5145) · jashkenas/coffeescript@63ffe0a

Original file line numberDiff line numberDiff line change

@@ -1922,3 +1922,16 @@ test "#4609: Support new.target", ->

19221922
19231923

new Foo()

19241924

eq newTarget, yes

1925+
1926+

test "#5085: Bug: @ reference to class not maintained in do block", ->

1927+

thisFoo = 'initial foo'

1928+

thisBar = 'initial bar'

1929+

fn = (o) -> o.bar()

1930+
1931+

class A

1932+

@foo = 'foo assigned in class'

1933+

do => thisFoo = @foo

1934+

fn bar: => thisBar = @foo

1935+
1936+

eq thisFoo, 'foo assigned in class'

1937+

eq thisBar, 'foo assigned in class'