Range expressions > 20 not working in REPL #1409

Closed
ricardobeat opened this Issue Jun 2, 2011 · 2 comments

Projects

None yet

2 participants

@ricardobeat
coffee> [1..5]
[1, 2, 3, 4, 5]
coffee> [1..100]
ReferenceError: arguments is not defined

From looking at a59df2c anything smaller than 21 will be compiled to an array literal, everything else will compile to a generator function which passes arguments as a parameter to itself.

(function() {
  _results = [];
  for (_i = 1; _i <= 100; _i++){ _results.push(_i); }
  return _results;
}).apply(this, arguments);

Since we're not running in a closure it fails. Why is that argument even there?

Slightly unrelated

Is the difference between [1..10] and [1...10] documented anywhere? I don't see "range expression" mentioned either at coffeescript.org.

@michaelficarra
Collaborator

@ricardobeat: arguments is there for cases like [0..arguments[0]].

@michaelficarra michaelficarra added a commit that referenced this issue Jun 2, 2011
@michaelficarra michaelficarra test for #1409 e240621
@michaelficarra
Collaborator

@ricardobeat: this should be fixed on master by the above commit

@michaelficarra michaelficarra added a commit that referenced this issue Jun 2, 2011
@michaelficarra michaelficarra enhancement for fix to #1409: when compiling as an array, ranges can't
have been given steps (would be a SyntaxError) ... yet
8ce1fdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment