jashkenas / jashkenas/coffeescript
Bug: Wrong `this` in bound methods of nested classes
- Dominant language
- CoffeeScript
- Stars
- 16.6k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
While upgrading an application to CS2 we ran into the following issue in an obscure usage of nested classes.

As you can see, the nested bound method thought its `this` is the parent class. This seems to happen on a "parse" level, because it's replaced in the code. This lead to tricky to catch bug on our side.
Contributor guide
Research direction
The issue names no source file or test and provides its reproduction only in a screenshot. Start by reproducing the nested-class bound-method case in the CoffeeScript compiler and inspect the parse or transformation stage where `this` is replaced. Done means the nested bound method retains its own `this`, with a regression test covering the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- coffeescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100