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

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

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

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2877?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 `93.97590%` with `5 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 71.0931%. Comparing base 
([`8d6d4d7`](https://app.codecov.io/gh/apache/groovy/commit/8d6d4d7086e190e94ad654685e318d9f14780be4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`98ae712`](https://app.codecov.io/gh/apache/groovy/commit/98ae71244ef080ea8f5a97f03af89304cd5b7d04?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 3 commits behind head on master.
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2877?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...org/apache/groovy/parser/antlr4/AbstractLexer.java](https://app.codecov.io/gh/apache/groovy/pull/2877?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FAbstractLexer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0Fic3RyYWN0TGV4ZXIuamF2YQ==)
 | 94.2857% | [0 Missing and 2 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2877?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...antlr4/internal/AbstractFriendlyErrorStrategy.java](https://app.codecov.io/gh/apache/groovy/pull/2877?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=)
 | 95.6522% | [0 Missing and 2 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2877?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/2877?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/2877?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/2877/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/2877?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2877        +/-   ##
   ==================================================
   + Coverage     71.0832%   71.0931%   +0.0099%     
   - Complexity      37312      37372        +60     
   ==================================================
     Files            1578       1579         +1     
     Lines          135392     135511       +119     
     Branches        25086      25100        +14     
   ==================================================
   + Hits            96241      96339        +98     
   - Misses          30473      30483        +10     
   - Partials         8678       8689        +11     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2877?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...apache/groovy/parser/antlr4/GroovySyntaxError.java](https://app.codecov.io/gh/apache/groovy/pull/2877?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FGroovySyntaxError.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0dyb292eVN5bnRheEVycm9yLmphdmE=)
 | `80.0000% <ø> (ø)` | |
   | 
[...he/groovy/parser/antlr4/SyntaxErrorReportable.java](https://app.codecov.io/gh/apache/groovy/pull/2877?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FSyntaxErrorReportable.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L1N5bnRheEVycm9yUmVwb3J0YWJsZS5qYXZh)
 | `37.5000% <ø> (-4.1667%)` | :arrow_down: |
   | 
[...va/org/apache/groovy/parser/antlr4/AstBuilder.java](https://app.codecov.io/gh/apache/groovy/pull/2877?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==)
 | `86.6235% <50.0000%> (+0.0051%)` | :arrow_up: |
   | 
[...org/apache/groovy/parser/antlr4/AbstractLexer.java](https://app.codecov.io/gh/apache/groovy/pull/2877?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FAbstractLexer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0Fic3RyYWN0TGV4ZXIuamF2YQ==)
 | `94.5946% <94.2857%> (-5.4054%)` | :arrow_down: |
   | 
[...antlr4/internal/AbstractFriendlyErrorStrategy.java](https://app.codecov.io/gh/apache/groovy/pull/2877?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=)
 | `97.0149% <95.6522%> (-2.9851%)` | :arrow_down: |
   
   ... and [14 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/2877/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>




> Improve remaining common syntax error messages (unclosed literals, unexpected 
> characters, missing punctuation, reserved keywords)
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12353
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12353
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Daniel Sun
>            Priority: Major
>
> h3. Problem
> After GROOVY-12169 and GROOVY-12171, several everyday syntax mistakes still 
> produce a generic *Unexpected input* or *Unexpected character* message that 
> does not name the actual problem.
> Invisible characters (zero-width space, BOM, NUL, form feed) appear as an 
> empty glyph in quotes. Unclosed quotes and comments are reported as an 
> unexpected quote or slash rather than as an unclosed literal. {{if true}} 
> without parentheses, {{x ? y}}, and {{const x = 1}} look like random 
> unexpected tokens instead of a missing {{(}} / {{:}} or an unimplemented 
> keyword.
> h3. Examples (before)
>  * Source:
> {noformat}
> println 'Hello
> {noformat}
> Report:
> {noformat}
> Unexpected character: ''' @ line 1, column 9.
> {noformat}
> (caret on the opening quote)
>  * Source:
> {noformat}
> /* comment
> {noformat}
> Report:
> {noformat}
> Unexpected input: '/'
> {noformat}
> (no mention of an unclosed comment)
>  * Source: {{def}} + zero-width space + {{name = null}}
> Report:
> {noformat}
> Unexpected character: ''
> {noformat}
> (the offending character is invisible)
>  * Source:
> {noformat}
> if true { x = 1 }
> {noformat}
> Report:
> {noformat}
> Unexpected input: 'true'
> {noformat}
>  * Source:
> {noformat}
> const x = 1
> {noformat}
> Report:
> {noformat}
> Unexpected input: 'const'
> {noformat}
>  * Source:
> {noformat}
> def n = 1_
> {noformat}
> Report:
> {noformat}
> Number ending with underscores is invalid @ line 1, column 10 @ line 1, 
> column 10.
> {noformat}
> (position duplicated)
>  * Source:
> {noformat}
> def m(int... a, int b) {}
> {noformat}
> Report:
> {noformat}
> The var-arg parameter strs must be the last parameter
> {noformat}
> (hard-coded name {{strs}})
> h3. Root cause
>  * Lexer {{UNEXPECTED_CHAR}} inlined the raw character with only a 
> quote-escape, so control / format characters vanish in the message. An 
> unexpected quote is almost always an unclosed string, but the message never 
> said so.
>  * Unclosed block comments failed the comment rule and were retokenised as 
> {{/}}, so the parser saw an unexpected slash.
>  * Parser fallback wording was still ANTLR's *Unexpected input*, even when 
> the expected set was a single punctuation token (open paren, colon, {{>}}) or 
> the offending token was a reserved keyword ({{const}}, {{goto}}, {{else}}, 
> {{catch}}, {{finally}}, {{case}}) or EOF.
>  * Lexer {{require(..., true)}} appended {{@ line N, column M}} to 
> {{GroovySyntaxError}}, and {{SyntaxException}} appended the same location 
> again.
>  * {{AstBuilder}} used a hard-coded parameter name {{strs}} in the 
> varargs-not-last diagnostic.
> Grammar-level parser error alternatives are not an option: GROOVY-9588 showed 
> they enlarge the ATN and slow successful parses.
> h3. Goal
> Give javac-aligned, developer-facing sentences for these common mistakes, 
> with an accurate caret, without reintroducing parser error alternatives on 
> the hot path.
> h3. Approach
> Error-path-only, two layers:
>  * Lexer ({{GroovyLexer.g4}} / {{AbstractLexer}}): unexpected quote becomes 
> *Unclosed string literal*; unclosed block comment becomes *Unclosed comment* 
> at the opener (same-rule EOF alternative, not a second lexer rule); other 
> unexpected characters via {{getCharErrorDisplay}} (shared with the GString 
> {{$}} path from GROOVY-12171). Stop attaching position text on lexer 
> {{require}} calls so {{SyntaxException}} is the only source of {{@ line N, 
> column M}}.
>  * Parser ({{AbstractFriendlyErrorStrategy}}): {{MissingDelimiterDiagnostic}} 
> still relocates the caret for a missing closer (GROOVY-12169). Everything 
> else only refines the fallback sentence and keeps ANTLR's offending token: 
> reserved/misplaced keyword, then a singleton expected punctuation token 
> ({{Missing '('}}, {{Missing ':'}}, {{Missing '>'}}, ...), then *Unexpected 
> end of input* for EOF.
> {{AstBuilder}} reports the actual varargs parameter name.
> h3. Expected result (after)
>  * unclosed single-quoted string becomes *Unclosed string literal*
>  * unclosed block comment becomes *Unclosed comment* (caret on the opener)
>  * zero-width space in an identifier becomes {{Unexpected character: 
> '\u200b'}}
>  * {{if true}} without parentheses becomes {{Missing '('}}
>  * {{x ? y}} becomes {{Missing ':'}}
>  * a generic type missing {{>}} before {{(}} becomes {{Missing '>'}}
>  * {{const x = 1}} becomes {{'const' is not supported; use 'val' or 'static 
> final' instead}}
>  * {{goto label}} becomes {{'goto' is not supported}}
>  * stray {{else}} / {{catch}} / {{case}} become {{'else' without 'if'}} / 
> {{'catch' without 'try'}} / {{'case' outside of switch}}
>  * {{throw}} at EOF becomes *Unexpected end of input*
>  * {{def n = 1_}} becomes *Number ending with underscores is invalid* 
> (position once)
>  * {{def m(int... a, int b)}} with a later parameter becomes {{The var-arg 
> parameter a must be the last parameter}}
> Valid programs are unchanged. Successful parses never enter these helpers.
> h3. Related
> GROOVY-12169, GROOVY-12171, GROOVY-9588, GROOVY-10146



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to