Skip to content

Commit 1f5b19b

Browse files
committed
slightly better conditions for range steps
1 parent 8a98cb3 commit 1f5b19b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/coffee-script/nodes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@
10831083
varPart += ", " + this.step;
10841084
}
10851085
_ref2 = ["" + idx + " <" + this.equals, "" + idx + " >" + this.equals], lt = _ref2[0], gt = _ref2[1];
1086-
condPart = this.stepNum ? +this.stepNum > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref3 = [+this.fromNum, +this.toNum], from = _ref3[0], to = _ref3[1], _ref3), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar);
1086+
condPart = this.stepNum ? +this.stepNum > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref3 = [+this.fromNum, +this.toNum], from = _ref3[0], to = _ref3[1], _ref3), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = this.stepVar ? "" + this.stepVar + " > 0" : "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar);
10871087
stepPart = this.stepVar ? "" + idx + " += " + this.stepVar : known ? namedIndex ? from <= to ? "++" + idx : "--" + idx : from <= to ? "" + idx + "++" : "" + idx + "--" : namedIndex ? "" + cond + " ? ++" + idx + " : --" + idx : "" + cond + " ? " + idx + "++ : " + idx + "--";
10881088
if (namedIndex) {
10891089
varPart = "" + idxName + " = " + varPart;

src/nodes.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ exports.Range = class Range extends Base
717717
[from, to] = [+@fromNum, +@toNum]
718718
if from <= to then "#{lt} #{to}" else "#{gt} #{to}"
719719
else
720-
cond = "#{@fromVar} <= #{@toVar}"
720+
cond = if @stepVar then "#{@stepVar} > 0" else "#{@fromVar} <= #{@toVar}"
721721
"#{cond} ? #{lt} #{@toVar} : #{gt} #{@toVar}"
722722

723723
# Generate the step.

0 commit comments

Comments
 (0)