jashkenas / jashkenas/coffeescript

Bug: Excessive variable and shallow copy for leading or middle rest parameter

Open
#5,444 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
f1 = (a..., b) ->

f2 = (c, d..., e) ->
Expected Behavior
var f1, f2,
  splice = [].splice;

f1 = function(...a) {
  var b;
  [b] = splice.call(a, -1);
};

f2 = function(c, ...d) {
  var e;
  [e] = splice.call(d, -1);
};
Current Behavior
var f1, f2,
  splice = [].splice;

f1 = function(...a) {
  var b, ref;
  ref = a, [...a] = ref, [b] = splice.call(a, -1);
};

f2 = function(c, ...d) {
  var e, ref;
  ref = d, [...d] = ref, [e] = splice.call(d, -1);
};
Environment
  • CoffeeScript version: 2.7.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

Reproduce the issue with the f1 and f2 input snippets using CoffeeScript 2.7.0, then trace the compiler path that handles leading and middle rest parameters. Compare the generated JavaScript with the expected output; done means the redundant variable and shallow-copy operations are no longer emitted.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.