Skip to content

GROOVY-12098: Pre/post increment on array element double-evaluates th…#2621

Merged
paulk-asert merged 1 commit into
apache:masterfrom
paulk-asert:groovy12098
Jun 24, 2026
Merged

GROOVY-12098: Pre/post increment on array element double-evaluates th…#2621
paulk-asert merged 1 commit into
apache:masterfrom
paulk-asert:groovy12098

Conversation

@paulk-asert

Copy link
Copy Markdown
Contributor

…e receiver

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds regression coverage and fixes bytecode generation so pre/post inc/dec on subscript expressions (a[i]++, ++a[i], etc.) evaluates the receiver and index exactly once and in left-to-right order.

Changes:

  • Introduces a new regression test suite for GROOVY-12098 covering order, single-evaluation, and value semantics for arrays/lists (including @CompileStatic cases).
  • Updates BinaryExpressionHelper to cache both subscript receiver and index into temporaries and reuse them for the read (getAt) and write (putAt) paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/test/groovy/bugs/Groovy12098.groovy Adds regression tests verifying evaluation order, single-evaluation, and correct values for array/list subscript inc/dec.
src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionHelper.java Caches subscript receiver+index into temporaries to prevent double-evaluation during read-modify-write operations.

Comment thread src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionHelper.java Outdated
Comment thread src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionHelper.java Outdated
@codecov-commenter

codecov-commenter commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.4796%. Comparing base (40c6203) to head (19149bb).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...us/groovy/classgen/asm/BinaryExpressionHelper.java 96.5517% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2621        +/-   ##
==================================================
+ Coverage     68.4541%   68.4796%   +0.0255%     
- Complexity      33505      33524        +19     
==================================================
  Files            1518       1518                
  Lines          127107     127124        +17     
  Branches        23065      23064         -1     
==================================================
+ Hits            87010      87054        +44     
+ Misses          32371      32333        -38     
- Partials         7726       7737        +11     
Files with missing lines Coverage Δ
...us/groovy/classgen/asm/BinaryExpressionHelper.java 88.9580% <96.5517%> (+0.1401%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

testlens-app Bot commented Jun 23, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 19149bb
▶️ Tests: 87857 executed
⚪️ Checks: 30/30 completed


Learn more about TestLens at testlens.app.

@paulk-asert paulk-asert merged commit 4527fcd into apache:master Jun 24, 2026
31 checks passed
@paulk-asert paulk-asert deleted the groovy12098 branch June 24, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants