You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/07/05 03:52:00 UTC

[jira] [Commented] (GROOVY-12128) loop contract checks fire at points that disagree with loop semantics

    [ https://issues.apache.org/jira/browse/GROOVY-12128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18093743#comment-18093743 ] 

ASF GitHub Bot commented on GROOVY-12128:
-----------------------------------------

paulk-asert opened a new pull request, #2665:
URL: https://github.com/apache/groovy/pull/2665

   …hat disagree with loop semantics
   
   A do-while runs its body before the first condition check, so its loop @Invariant only needs to be established by that first body execution; checking it at loop entry rejected valid loops. The invariant is now checked after each body execution for do-while (start-of-iteration placement is unchanged for for/while), and is intentionally not checked at break exits, matching standard loop-invariant semantics.
   
   A @Decreases variant was measured at the start and end of a single pass, which misses progress made by a classic for loop's update expression (it runs after the body end) and demanded non-negativity after the final body execution. The variant is now evaluated once at the start of each iteration: a scalar measure must be non-negative at entry (well-foundedness), and consecutive iteration-start values must strictly decrease. The cross-iteration state is hoisted into the block directly enclosing the loop; when the loop is not a direct child of a block (e.g. a braceless if branch), the previous single-pass measurement is kept as a fallback.




> loop contract checks fire at points that disagree with loop semantics
> ---------------------------------------------------------------------
>
>                 Key: GROOVY-12128
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12128
>             Project: Groovy
>          Issue Type: Improvement
>          Components: groovy-contracts
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 6.0.0-beta-1
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)