jashkenas / jashkenas/coffeescript

Lexer: Provide more helpful error message for trailing colon

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

Description

If you accidentally add a colon at the end of a line, like in Python, the CoffeeScript compiler (HEAD) produces rather unhelpful error messages. I ended up spending some time yesterday hunting down an extra colon in the middle of my source. ;-)

```
$ bin/coffee -sc
while 1:
1
Error: Parse error on line 2: Unexpected 'TERMINATOR'

$ bin/coffee -sc
for i in [1]:
1
Error: Parse error on line 1: Unexpected '{'
```

This is not really a bug, more like a nuisance -- just thought you might appreciate the report. Feel free to close it if there is nothing that can be done.

Contributor guide

Open the contributing guide

Research direction

Reproduce the two examples with bin/coffee -sc and inspect the lexer/parser error-handling path for trailing colons. Done means both examples report a helpful, specific diagnostic instead of the current unexpected-token errors, without regressing normal CoffeeScript syntax.

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.