[
https://issues.apache.org/jira/browse/GROOVY-12478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18134027#comment-18134027
]
ASF GitHub Bot commented on GROOVY-12478:
-----------------------------------------
codecov-commenter commented on PR #3009:
URL: https://github.com/apache/groovy/pull/3009#issuecomment-6490345435
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3009?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
Report
:x: Patch coverage is `90.76923%` with `6 lines` in your changes missing
coverage. Please review.
:white_check_mark: Project coverage is 73.6181%. Comparing base
([`d82dc98`](https://app.codecov.io/gh/apache/groovy/commit/d82dc98590867204f7ffbf8fb68b473b68cd6d72?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`b361b9a`](https://app.codecov.io/gh/apache/groovy/commit/b361b9ac35155ec0ef377e5a7898c4d3e6c66ade?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3009?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Patch % | Lines |
|---|---|---|
|
[...java/org/codehaus/groovy/classgen/ReturnAdder.java](https://app.codecov.io/gh/apache/groovy/pull/3009?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2FReturnAdder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL1JldHVybkFkZGVyLmphdmE=)
| 83.3333% | [1 Missing and 2 partials :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3009?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...va/org/apache/groovy/parser/antlr4/AstBuilder.java](https://app.codecov.io/gh/apache/groovy/pull/3009?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FAstBuilder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0FzdEJ1aWxkZXIuamF2YQ==)
| 95.6522% | [2 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3009?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...ava/org/codehaus/groovy/control/LabelVerifier.java](https://app.codecov.io/gh/apache/groovy/pull/3009?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fcontrol%2FLabelVerifier.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NvbnRyb2wvTGFiZWxWZXJpZmllci5qYXZh)
| 0.0000% | [0 Missing and 1 partial :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3009?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/groovy/pull/3009?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #3009 +/- ##
==================================================
+ Coverage 73.5991% 73.6181% +0.0190%
- Complexity 42419 42446 +27
==================================================
Files 1677 1677
Lines 146688 146737 +49
Branches 27723 27737 +14
==================================================
+ Hits 107961 108025 +64
+ Misses 28613 28601 -12
+ Partials 10114 10111 -3
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3009?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...ava/org/codehaus/groovy/control/LabelVerifier.java](https://app.codecov.io/gh/apache/groovy/pull/3009?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fcontrol%2FLabelVerifier.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NvbnRyb2wvTGFiZWxWZXJpZmllci5qYXZh)
| `84.9398% <0.0000%> (ø)` | |
|
[...va/org/apache/groovy/parser/antlr4/AstBuilder.java](https://app.codecov.io/gh/apache/groovy/pull/3009?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FAstBuilder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0FzdEJ1aWxkZXIuamF2YQ==)
| `87.4585% <95.6522%> (+0.3316%)` | :arrow_up: |
|
[...java/org/codehaus/groovy/classgen/ReturnAdder.java](https://app.codecov.io/gh/apache/groovy/pull/3009?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2FReturnAdder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL1JldHVybkFkZGVyLmphdmE=)
| `91.5966% <83.3333%> (-1.4727%)` | :arrow_down: |
... and [12 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3009/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests,
report on failures, and find test suite problems.
- :package: [JS Bundle
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save
yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
> yield before the last statement of an arrow-switch arm is ignored when the
> switch is compiled as a statement
> ------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12478
> URL: https://issues.apache.org/jira/browse/GROOVY-12478
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 6.0.0
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
> Fix For: 7.0.0-alpha-1, 6.0.1
>
>
> A {{yield}} that is not the last statement of an arrow-switch block arm is
> silently ignored when the switch ends up classified as a statement: execution
> falls through to the rest of the arm instead of completing the switch.
> {code:groovy}
> def pick(boolean flag) {
> switch (1) {
> case 1 -> {
> if (flag) yield 'first'
> yield 'second'
> }
> }
> }
> assert pick(true) == 'first' // fails on 6.0.0: 'second'
> {code}
> The same thing happens when the switch's value is discarded (the code after
> the conditional {{yield}} still runs), and a {{yield}} inside a loop within
> the arm no longer compiles:
> {code:groovy}
> def pick(List xs) {
> switch (1) {
> case 1 -> {
> for (x in xs) { if (x > 2) yield "big $x" }
> yield 'none'
> }
> }
> }
> // 6.0.0: "the yield statement is only allowed inside a switch expression"
> {code}
> ||Case||5.1.2||6.0.0-RC-1||6.0.0-RC-3 / 6.0.0||
> |Trailing switch, {{pick(true)}}|'first'|'first'|*'second'*|
> |Value discarded, conditional {{yield}}|arm exits|arm exits|*falls through*|
> |{{yield}} inside a loop in the arm|works|works|*compile error*|
> |{{return switch (...)}}|'first'|'first'|'first'|
> Behaviour is the same in dynamic Groovy and under {{@CompileStatic}}.
> *Cause:* since GROOVY-12408 a trailing switch is a statement, and the parser
> rewrites statement-position arrow switches via
> {{AstBuilder.armCodeAsStatement}}, which replaces each {{yield x}} with a
> plain expression statement {{x}}. Only the last value of the arm reaches
> {{ReturnAdder}}, so a final {{yield}} still appears to work, but any earlier
> {{yield}} loses its jump. The rewrite does not descend into loops, so a
> nested {{yield}} survives as a {{YieldStatement}} and is then rejected.
> The related rejection of {{return}}, {{break}} and {{continue}} in every
> arrow arm ("switch expression does not support `return`") dates from when
> arrow switches were implemented as closures, where a {{return}} would only
> have left the closure; 6.0 compiles switches inline and makes
> statement-position ones real switch statements, so that restriction should
> now depend on position as well.
> *Expected:* {{yield}} keeps its early-exit meaning wherever the switch's
> position puts it. GROOVY-12408 was meant to change only how a trailing switch
> is encoded, and 4.x/5.x code had to use {{yield}} in block arms of exactly
> these switches. In return position, a {{yield}} should behave like
> {{return}}. Elsewhere it should evaluate its expression and exit the switch.
> *Suggested fix:* keep the {{YieldStatement}} s instead of flattening them.
> Let {{ReturnAdder}} turn the yields belonging to a return-position switch
> into returns, searching the whole arm including loops but stopping at nested
> switch expressions and closures. Compile any remaining {{yield}} in a switch
> statement as "evaluate, discard, jump to the switch's end label", which also
> makes the loop case work.
> *Workaround:* write return switch (...) { ... } so the switch stays an
> expression, or restructure the arm so its only {{yield}} is the last
> statement (e.g. if/else with a {{yield}} in each branch).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)