jashkenas / jashkenas/coffeescript

Bug: Dangling else in function calls

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

Description

I remember discussing dangling else in this repo but I can't seem to find the issue anymore. We did not discuss this specific case tho and I do think it's a bug.

### [Input Code](https://coffeescript.org/v2/#try:if%20coffee%20then%20if%20latte%20then%201%20else%200%0A%0Aif%20coffee%20then%20brew%20if%20latte%20then%201%20else%200%0A)
```coffee
if coffee then if latte then 1 else 0

if coffee then brew if latte then 1 else 0
```
### Expected Behavior
```js
if (coffee) {
if (latte) {
1;
} else {
0;
}
}

if (coffee) {
brew(latte ? 1 : 0);
}
```
### Current Behavior
```js
if (coffee) {
if (latte) {
1;
} else {
0;
}
}

if (coffee) {
brew(latte ? 1 : void 0);
} else {
0;
}
```
### Possible Solution

### Context

### Environment

* CoffeeScript version: 2.3.2
* Node.js version: any

Contributor guide

Open the contributing guide

Research direction

Start by compiling the two input examples in the linked CoffeeScript playground and compare the generated JavaScript with the expected and current behavior shown here. Trace the compiler’s handling of nested conditionals in function-call syntax; done means the second example produces the expected output without changing the correct first example.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.