Github user paplorinc commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/360#discussion_r69197616
  
    --- Diff: src/main/groovy/lang/IntRange.java ---
    @@ -377,40 +382,52 @@ public boolean containsAll(Collection other) {
     
         @Override
         public void step(int step, Closure closure) {
    -        if (step == 0) {
    -            if (!getFrom().equals(getTo())) {
    +        step((Number) step, closure);
    +    }
    +
    +    /**
    +     * {@inheritDoc}
    +     */
    +    @Override
    +    public void step(Number step, Closure closure) {
    +        final Long from = getFrom().longValue();
    +        final Long to = getTo().longValue();
    +
    +        if (compareEqual(step, 0)) {
    +            if (compareNotEqual(from, to)) {
                     throw new GroovyRuntimeException("Infinite loop detected 
due to step size of 0");
                 } else {
                     return; // from == to and step == 0, nothing to do, so 
return
                 }
             }
     
    -        if (isReverse()) {
    -            step = -step;
    +        boolean isAscending = !isReverse();
    +        if (compareLessThan(step, 0)) {
    +            step = multiply(step, -1);
    +            isAscending = !isAscending;
    --- End diff --
    
    if the step is negative, we're going backwards, i.e. it's not ascending 
anymore


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to