Github user paulk-asert commented on a diff in the pull request: https://github.com/apache/groovy/pull/360#discussion_r71060369 --- Diff: src/main/groovy/lang/IntRange.java --- @@ -385,26 +385,23 @@ public void step(int step, Closure closure) { return; // from == to and step == 0, nothing to do, so return } - if (isReverse()) { - step = -step; + final long from = getFrom().longValue(), to = getTo().longValue(); + + final boolean isAscending; + if (step < 0) { + step *= -1; + isAscending = isReverse(); + } else { + isAscending = !isReverse(); } - if (step > 0) { - int value = getFrom(); - while (value <= getTo()) { + + if (isAscending) { + for (long value = from; value <= to; value += step) { closure.call(value); - if (((long) value + step) >= Integer.MAX_VALUE) { - break; - } - value = value + step; } } else { - int value = getTo(); - while (value >= getFrom()) { + for (long value = to; value >= from; value -= step) { --- End diff -- The issue with the long value being passed to the closure is that it breaks existing code, e.g.: `(0..3).step(2){ int i -> println i * 2 } `
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---