Github user paulk-asert commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/360#discussion_r70180330
  
    --- Diff: src/main/groovy/lang/IntRange.java ---
    @@ -379,32 +379,25 @@ public boolean containsAll(Collection other) {
         @Override
         public void step(int step, Closure closure) {
             if (step == 0) {
    -            if (!getFrom().equals(getTo())) {
    -                throw new GroovyRuntimeException("Infinite loop detected 
due to step size of 0");
    -            }
    -            return; // from == to and step == 0, nothing to do, so return
    +            return;
    --- End diff --
    
    This seems controversial to me. If I had a for loop:
    ```
    for (int x = 0; x < 5; x += 0) { }
    ```
     I would expect an infinite loop (except for the case of the upper bound 
being the same as the initial value which we handle separately anyway) rather 
than the compiler optimizing it away to a no-op. So the previous early 
detection and exception makes more sense to me. Groovy does often give 
shortcuts to handle cases that might be errors in a more elegant way but this 
seems to be a bigger magical step than normal.


---
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.
---

Reply via email to