jashkenas / jashkenas/coffeescript

constructor renaming parameters

Open
#4,865 25 comments 0 reactions 0 assignees View on GitHub
duplicate
Dominant language
CoffeeScript
Stars
16.6k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

If you do this

```coffeescript
class Blah
constructor:(@thing)->
@thing()

method:->
thing = "hi"
```

Coffeescript compiles to

```javascript
var Blah;

Blah = class Blah {
constructor(thing1) {
this.thing = thing1;
this.thing();
}

method() {
var thing;
return thing = "hi";
}

};
```

Why the 1 after the thing?? I'm using an dependency injection system, and the rename is playing havoc with it. Coffeescript 1 didn't do this.

Contributor guide

Open the contributing guide

Research direction

Start by compiling the minimal CoffeeScript reproduction in the issue and compare the generated constructor parameter with the CoffeeScript 1 behavior described. Trace the compiler's parameter-renaming path and confirm the dependency-injection case is preserved without the unexpected suffix; add or update a regression test if the relevant test location is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
coffeescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.