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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3216?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 `71.92982%` with `16 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 74.1580%. Comparing base 
([`d86ea7e`](https://app.codecov.io/gh/apache/groovy/commit/d86ea7eb853ec19d069ec99e3ad478f4186b7d54?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`b771890`](https://app.codecov.io/gh/apache/groovy/commit/b7718907b79db31d9d2758285f3eb5ecf8c1289b?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/3216?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...antlr4/internal/AbstractFriendlyErrorStrategy.java](https://app.codecov.io/gh/apache/groovy/pull/3216?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2Finternal%2FAbstractFriendlyErrorStrategy.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L2ludGVybmFsL0Fic3RyYWN0RnJpZW5kbHlFcnJvclN0cmF0ZWd5LmphdmE=)
 | 72.7273% | [6 Missing and 9 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3216?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/3216?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==)
 | 50.0000% | [1 Missing :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3216?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>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3216/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/3216?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3216        +/-   ##
   ==================================================
   + Coverage     74.1563%   74.1580%   +0.0016%     
   - Complexity      43738      43772        +34     
   ==================================================
     Files            1692       1692                
     Lines          149549     149605        +56     
     Branches        28371      28386        +15     
   ==================================================
   + Hits           110900     110944        +44     
   - Misses          28437      28444         +7     
   - Partials        10212      10217         +5     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3216?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...va/org/apache/groovy/parser/antlr4/AstBuilder.java](https://app.codecov.io/gh/apache/groovy/pull/3216?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.4816% <50.0000%> (+0.0092%)` | :arrow_up: |
   | 
[...antlr4/internal/AbstractFriendlyErrorStrategy.java](https://app.codecov.io/gh/apache/groovy/pull/3216?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2Finternal%2FAbstractFriendlyErrorStrategy.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L2ludGVybmFsL0Fic3RyYWN0RnJpZW5kbHlFcnJvclN0cmF0ZWd5LmphdmE=)
 | `90.2174% <72.7273%> (-2.3935%)` | :arrow_down: |
   
   ... and [9 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3216/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>




> Primitive type keyword used as a variable name gets inconsistent and 
> misleading diagnostics
> -------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12695
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12695
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> *Environment:* macOS 26.5, BellSoft Liberica JDK 21.0.12; reproduced with the 
> {{groovy}} command of each distribution
> h3. Problem
> Declaring a local variable named after a primitive type keyword is rejected 
> (as it should be), but the message depends on which declaration keyword was 
> used, and neither message says what is wrong.
> {code}
> var long = 1
> val long = 1
> def long = 1
> final long = 1
> {code}
> h3. Actual
> {{var}} and {{val}} report a resolve-phase message that talks about assigning 
> to a class, with the caret on the keyword:
> {noformat}
> var_long.groovy: 1: you tried to assign a value to the class 'long'
>  @ line 1, column 5.
>    var long = 1
>        ^
> {noformat}
> {noformat}
> val_long.groovy: 1: you tried to assign a value to the class 'long'
>  @ line 1, column 5.
>    val long = 1
>        ^
> {noformat}
> {{def}} and {{final}} report a generic syntax error with the caret on the 
> {{=}}, one token past the mistake:
> {noformat}
> def_long.groovy: 1: Unexpected input: 'def long =' @ line 1, column 10.
>    def long = 1
>             ^
> {noformat}
> {noformat}
> final_long.groovy: 1: Unexpected input: 'final long =' @ line 1, column 12.
>    final long = 1
>               ^
> {noformat}
> Other primitive names and {{void}} behave the same way ({{var int = 1}} 
> reports {{you tried to assign a value to the class 'int'}}, {{def int = 1}} 
> reports {{Unexpected input: 'def int ='}}). Inside a method body {{def long = 
> 1}} reports {{Unexpected input: '='}} on the {{=}}. The same two shapes also 
> appear for a typed declaration ({{String long = "x"}} and {{int long = 1}} 
> report the class message, a field {{class C { int long = 1 }}} reports 
> {{Unexpected input: 'int long'}}) and for a bare {{long = 1}}.
> h3. Cause
> {{var}} and {{val}} are soft keywords, so when {{var long = 1}} fails to 
> parse as a declaration the parser accepts it as the command expression 
> {{var(long = 1)}}; {{AstBuilder}} builds an assignment whose left-hand side 
> is the built-in type name, and {{ResolveVisitor}} later reports it as an 
> assignment to a class. ({{var long}} without an initializer actually runs, as 
> a call to a method named {{var}}.) {{def}} and {{final}} are reserved, so the 
> parser commits to a declaration, consumes {{long}} as the declared type and 
> fails on the {{=}} with the generic {{Unexpected input}} sentence.
> h3. Expected
> One diagnostic for every form, naming the keyword, with the caret on the 
> keyword:
> {noformat}
> 'long' is a keyword and cannot be used as a variable name @ line 1, column 5.
>    var long = 1
>        ^
> {noformat}
> This is in line with the other developer-facing parser sentences added in 
> GROOVY-12353 and GROOVY-12401.
> A pull request with regression tests follows.
> h3. Versions
> Reproduced on 6.0.0, 6.0.1-SNAPSHOT (GROOVY_6_0_X at 7c0dcf17dd) and master 
> (d86ea7eb85).



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

Reply via email to