jashkenas / jashkenas/coffeescript

Bug: Loop control statements are allowed where they are invalid

Open
#5,333 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CoffeeScript
Stars
16.6k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

Input Code

#try

continue
break

for item in iterable then do (item) ->
  if await item
    continue
  else
    break
Expected Behavior

Compile Error: Unexpected token

Current Behavior
continue;
break;
var i, item, len;

for (i = 0, len = iterable.length; i < len; i++) {
  item = iterable[i];
  (async function(item) {
    if ((await item)) {
      continue;
    } else {
      break;
    }
  })(item);
}
Context

The current output is invalid javascript.

Environment
  • CoffeeScript: v2.5.1
  • Node.js: v14.13.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the provided CoffeeScript snippet as the reproduction case and inspect the compiler path that accepts the top-level and nested continue and break statements. Completion means compilation rejects these invalid statements with an "Unexpected token" error instead of emitting invalid JavaScript.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.