GROOVY-11792: for-in loop variable captured by closure/AIC sees final value, not per-iteration value - #2732
Conversation
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: 1d013d9 | Previous: c513a3a | Ratio |
|---|---|---|---|
org.apache.groovy.bench.CalibrationBench.memoryPointerChase |
1006.5323072503194 us/op |
574.7046880620453 us/op |
1.75 |
This comment was automatically generated by workflow using github-action-benchmark.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2732 +/- ##
==================================================
+ Coverage 69.3657% 69.4017% +0.0359%
- Complexity 35082 35100 +18
==================================================
Files 1553 1553
Lines 131490 131517 +27
Branches 24045 24047 +2
==================================================
+ Hits 91209 91275 +66
+ Misses 32045 31994 -51
- Partials 8236 8248 +12
🚀 New features to boost your workflow:
|
JMH summary — classic (commit
|
| Group | Speedup | Calibrated | n |
|---|---|---|---|
| bench | 1.240 × | 1.027 × | 92 |
| core | 1.071 × | 1.077 × | 77 |
| grails | 1.013 × | 1.024 × | 80 |
⚠️ Runner speed differs ≥15% from the historical baseline hardware for: bench. Raw speedups are not meaningful for those parts — use the calibrated column.
Runner calibration (this run vs baseline hardware): bench 1.21× (26 rulers) · core-ag 0.99× (3 rulers) · core-hz 1.00× (3 rulers) · grails-ad 0.97× (3 rulers) · grails-ez 1.00× (3 rulers)
Baseline: dev/bench/jmh/<part>/classic/data.js on gh-pages, trailing 90 days. Daily dashboard · Per-suite raw data
JMH summary — indy (commit
|
| Group | Speedup | Calibrated | n |
|---|---|---|---|
| bench | 0.992 × | 0.976 × | 92 |
| core | 3.537 × | 3.615 × | 77 |
| grails | 2.838 × | 2.591 × | 80 |
⚠️ Runner speed differs ≥15% from the historical baseline hardware for: grails-ez. Raw speedups are not meaningful for those parts — use the calibrated column.
Runner calibration (this run vs baseline hardware): bench 1.01× (26 rulers) · core-ag 0.99× (3 rulers) · core-hz 0.96× (3 rulers) · grails-ad 0.98× (3 rulers) · grails-ez 1.20× (3 rulers)
Baseline: dev/bench/jmh/<part>/indy/data.js on gh-pages, trailing 90 days. Daily dashboard · Per-suite raw data
blackdrag
left a comment
There was a problem hiding this comment.
Could you add a test for the bytecode as well? Best would be a test that checks the old bytecode pattern for not being produced and a test checking for the new bytecode pattern. That also clearly documents the change
2e90e7f to
e3e7c9a
Compare
Hi Jochen, does the commit to add the test looks OK to you? |
… value, not per-iteration value
1197010 to
feaf480
Compare
paulk-asert
left a comment
There was a problem hiding this comment.
Approved but consider the following naming suggestion:
Flag naming, now rather than later. groovy.for.loop.capture / setForLoopCaptureEnabled doesn't say what it controls: classic for loops are not affected despite the name, and capture=false reads like "captures disabled" rather than "legacy shared binding." Something like groovy.forin.per.iteration.capture would be self-describing.
…n.capture Make the language-compat switch self-describing: it only affects for-in loops, and true means per-iteration capture (false is legacy shared binding).
|
✅ All tests passed ✅🏷️ Commit: 1d013d9 Learn more about TestLens at testlens.app. |



https://issues.apache.org/jira/browse/GROOVY-11792