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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3215?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 `86.66667%` with `4 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 74.1605%. 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 
([`5ca6040`](https://app.codecov.io/gh/apache/groovy/commit/5ca604047038cb7c8694ce03051e1e3401e5c717?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/3215?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...er/antlr4/internal/MissingDelimiterDiagnostic.java](https://app.codecov.io/gh/apache/groovy/pull/3215?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2Finternal%2FMissingDelimiterDiagnostic.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L2ludGVybmFsL01pc3NpbmdEZWxpbWl0ZXJEaWFnbm9zdGljLmphdmE=)
 | 86.6667% | [0 Missing and 4 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3215?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/3215/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/3215?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3215        +/-   ##
   ==================================================
   + Coverage     74.1563%   74.1605%   +0.0042%     
   - Complexity      43738      43750        +12     
   ==================================================
     Files            1692       1692                
     Lines          149549     149577        +28     
     Branches        28371      28381        +10     
   ==================================================
   + Hits           110900     110927        +27     
   - Misses          28437      28438         +1     
     Partials        10212      10212                
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3215?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...er/antlr4/internal/MissingDelimiterDiagnostic.java](https://app.codecov.io/gh/apache/groovy/pull/3215?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2Finternal%2FMissingDelimiterDiagnostic.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L2ludGVybmFsL01pc3NpbmdEZWxpbWl0ZXJEaWFnbm9zdGljLmphdmE=)
 | `93.3852% <86.6667%> (-0.9379%)` | :arrow_down: |
   
   ... and [12 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3215/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>




> Parser reports Missing ')' at an earlier closed paren group instead of the 
> actual syntax error
> ----------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12694
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12694
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> *Environment:* macOS 26.5 (Darwin 25.5.0), JDK 21.0.12 (BellSoft Liberica); 
> diagnostics taken from {{groovyc --check --error-format=short}}. Also 
> reproduces on 6.0.1-SNAPSHOT (GROOVY_6_0_X at 7c0dcf17dd) and master 
> 7.0.0-SNAPSHOT (d86ea7eb85).
> h3. Description
> A Java-style type pattern in a switch case label ({{case Circle c ->}}) is 
> not Groovy syntax, so the script below must fail to parse. When a record 
> declaration precedes the switch, however, the error is reported as {{Missing 
> ')'}} inside the record header on line 1 -- which parses fine on its own -- 
> instead of at the offending case label on line 3.
> h3. Reproducer
> {code:groovy}
> record Circle(double radius) {}
> Object o = new Circle(1)
> String s = switch (o) { case Circle c -> 'circle'; default -> 'other' }
> println s
> {code}
> h3. Actual
> {noformat}
> record.groovy:1:22: error: Missing ')'
> {noformat}
> Column 22 is {{radius}} in the record header. Replacing {{case Circle c ->}} 
> with {{case Circle ->}} makes the file compile, so there is nothing missing 
> on line 1.
> h3. Expected
> The diagnostic at the unsupported case label, which is what the same switch 
> gets when a plain class ({{class Circle { double radius }}}) precedes it 
> instead of the record:
> {noformat}
> record.groovy:3:37: error: Unexpected input: 'String s = switch (o) { case 
> Circle c'
> {noformat}
> h3. Scope
> The record is incidental. Any parenthesised group of the shape {{( <type> 
> <literal | identifier | (>}} that the parser has already accepted is reported 
> as a missing {{)}} whenever a syntax error occurs later in the file:
> {code:groovy}
> def foo(int x) { x }
> def y = 1 +
> {code}
> {noformat}
> Missing ')' @ line 1, column 13
> {noformat}
> Expected {{Unexpected input: '+' @ line 2, column 11}}, which is what the 
> second line reports on its own. The same happens with {{for (int i = 0; i < 
> 3; i++) { }}} or {{def y = (Math.max(1, 2))}} on the first line.
> h3. Cause
> {{org.apache.groovy.parser.antlr4.internal.MissingDelimiterDiagnostic#fromCastPattern}}
>  (the "unclosed cast" heuristic added for the friendlier missing-delimiter 
> messages) scans the whole token stream for {{'(' type <expr-start>}} and 
> reports the earliest match, without checking whether that group's {{)}} was 
> already matched before the point where the parser failed. A formal parameter 
> list with a primitive-typed parameter, a classic {{for}} header or a 
> parenthesised call all match that pattern. Restricting the scan to groups 
> that are still open at the failure point (the offending token, or the start 
> token of a failed {{NoViableAltException}} decision) fixes the position while 
> keeping the real unclosed-cast diagnostics ({{println ((int 123)}} still 
> reports at {{123}}).
> A pull request with regression tests follows.



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

Reply via email to