1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

enhancement for fix to #1409: when compiling as an array, ranges can't

have been given steps (would be a SyntaxError) ... yet
This commit is contained in:
Michael Ficarra 2011-06-02 09:28:13 -04:00
parent a0efdac8ce
commit 8ce1fdb5bb
2 changed files with 3 additions and 7 deletions

View file

@ -850,7 +850,7 @@
return n instanceof Literal && n.value === 'arguments' && !n.asKey;
}) : void 0;
};
if (hasArgs(this.from) || hasArgs(this.to) || hasArgs(this.step)) {
if (hasArgs(this.from) || hasArgs(this.to)) {
args = ', arguments';
}
return "(function() {" + pre + "\n" + idt + "for (" + body + ")" + post + "}).apply(this" + (args != null ? args : '') + ")";

View file

@ -693,12 +693,8 @@ exports.Range = class Range extends Base
cond = "#{@fromVar} <= #{@toVar}"
body = "var #{vars}; #{cond} ? #{i} <#{@equals} #{@toVar} : #{i} >#{@equals} #{@toVar}; #{cond} ? #{i}++ : #{i}--"
post = "{ #{result}.push(#{i}); }\n#{idt}return #{result};\n#{o.indent}"
hasArgs = (node) ->
node?.contains (n) ->
n instanceof Literal and
n.value is 'arguments' and
not n.asKey
args = ', arguments' if hasArgs(@from) or hasArgs(@to) or hasArgs(@step)
hasArgs = (node) -> node?.contains (n) -> n instanceof Literal and n.value is 'arguments' and not n.asKey
args = ', arguments' if hasArgs(@from) or hasArgs(@to)
"(function() {#{pre}\n#{idt}for (#{body})#{post}}).apply(this#{args ? ''})"
#### Slice