jashkenas / jashkenas/coffeescript

"multiple parameters named <value>" when destructuring params in args with duplicate default values

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

Description

Bug report

### Input Code

```coffee
baz = ({ foo: _foo = false, bar: _bar = false } = {}) ->
```

### Expected Behavior
```javascript
var baz;

baz = function(arg) {
var _bar, _foo, ref, ref1, ref2;
ref = arg != null ? arg : {}, _foo = (ref1 = ref.foo) != null ? ref1 : false, _bar = (ref2 = ref.bar) != null ? ref2 : false;
};
```

### Current Behavior
```
Error on line 1: multiple parameters named false
```

### Context
This often comes up with constructor params where you have several named params which all default to false

### Environment
This occurs with v1.12.7 but not whatever v2.x.x version is on the main (non-v2) website

* CoffeeScript version: v1.12.7
* Node.js version: v12.14.1

Contributor guide

Open the contributing guide

Research direction

Start by compiling the reported destructuring example with CoffeeScript v1.12.7 and compare the duplicate-default error with the expected JavaScript output. Trace the compiler entry point that reports "multiple parameters named false"; done means the example compiles and produces the shown parameter assignments without the erroneous duplicate-name error.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.