jashkenas/coffeescript

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

123-Notus opened this issue · 0 comments

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