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

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

codecov-commenter commented on PR #3315:
URL: https://github.com/apache/groovy/pull/3315#issuecomment-7033528264

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3315?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 74.5963%. Comparing base 
([`077ff21`](https://app.codecov.io/gh/apache/groovy/commit/077ff21217c82a6e26c5d06962947449250118ee?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`5e7c250`](https://app.codecov.io/gh/apache/groovy/commit/5e7c250ed6e71602e9bd849bae2dae19916d850d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3315/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/3315?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3315        +/-   ##
   ==================================================
   + Coverage     74.5922%   74.5963%   +0.0041%     
   - Complexity      45392      45399         +7     
   ==================================================
     Files            1707       1707                
     Lines          153244     153257        +13     
     Branches        29467      29466         -1     
   ==================================================
   + Hits           114308     114324        +16     
   - Misses          28422      28424         +2     
   + Partials        10514      10509         -5     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3315?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[.../main/java/org/codehaus/groovy/ast/ModuleNode.java](https://app.codecov.io/gh/apache/groovy/pull/3315?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2FModuleNode.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9Nb2R1bGVOb2RlLmphdmE=)
 | `89.2857% <100.0000%> (+0.4312%)` | :arrow_up: |
   
   ... and [11 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3315/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>




> A multiple-assignment declaration with a non-literal right-hand side is 
> dropped, with every later declaration, from a script with an instance main or 
> a run method
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12790
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12790
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>            Reporter: Paul King
>            Priority: Major
>
> In a script with no statements other than declarations, plus a {{main}} 
> method (the JEP 445 style class) or a no-arg {{run}} method, top-level 
> declarations are turned into fields. A multiple-assignment declaration whose 
> right-hand side is not a list literal is silently dropped instead, together 
> with every declaration that follows it.
> {code:groovy}
> def (a, b) = "xy".toList()
> def c = 3
> void main() { println "a=$a c=$c" }
> {code}
> fails with:
> {noformat}
> groovy.lang.MissingPropertyException: No such property: a for class: M
> {noformat}
> The generated class's declared fields:
> ||Script||Fields||
> |{{def (a, b) = [1, 2]; def c = 3; void main() {}}}|a, b, c|
> |{{def (a, b) = "xy".toList(); def c = 3; void main() {}}}|(none)|
> |{{def (a, b) = "xy".toList(); def c = 3; def run() {}}}|(none)|
> Neither {{a}}, {{b}} nor {{c}} becomes a field, and the declaration's 
> right-hand side is never evaluated. There is no compile error or warning.
> The cause is the declaration loop in {{ModuleNode.createStatementsClass()}}:
> {code:java}
> if (!(de.getRightExpression() instanceof ListExpression)) break;
> {code}
> The {{break}} leaves the loop without setting {{hasUncontainedStatements}}, 
> so the class is still built from the fields collected so far, and the 
> remaining declarations are discarded. The loop was added by GROOVY-11118 
> (5.0.0-alpha-1).
> Possible fixes: treat such a declaration as an uncontained statement, which 
> gives the normal script behaviour; or create the fields and assign them in an 
> instance initializer, which keeps the plain class.
> Reproduced on master at 077ff21217 and on 6.0.0-beta-2, both on JDK 17.0.20. 
> The same code is on GROOVY_5_0_X, GROOVY_5_1_X and GROOVY_6_0_X, but not on 
> GROOVY_4_0_X.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to