[
https://issues.apache.org/jira/browse/GROOVY-12171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18097237#comment-18097237
]
ASF GitHub Bot commented on GROOVY-12171:
-----------------------------------------
codecov-commenter commented on PR #2719:
URL: https://github.com/apache/groovy/pull/2719#issuecomment-5009477068
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2719?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 `76.19048%` with `5 lines` in your changes missing
coverage. Please review.
:white_check_mark: Project coverage is 69.1540%. Comparing base
([`406c015`](https://app.codecov.io/gh/apache/groovy/commit/406c015c8b47c2dc60b3c0b93d925b2dc82e7e88?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`4e6ac8f`](https://app.codecov.io/gh/apache/groovy/commit/4e6ac8fa3a5505ca5799e6cfd3747bb6465c9242?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/2719?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Patch % | Lines |
|---|---|---|
|
[...g/apache/groovy/parser/antlr4/GroovyLangLexer.java](https://app.codecov.io/gh/apache/groovy/pull/2719?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FGroovyLangLexer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0dyb292eUxhbmdMZXhlci5qYXZh)
| 76.1905% | [3 Missing and 2 partials :warning:
](https://app.codecov.io/gh/apache/groovy/pull/2719?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/2719?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #2719 +/- ##
==================================================
+ Coverage 69.1531% 69.1540% +0.0009%
- Complexity 34331 34339 +8
==================================================
Files 1538 1538
Lines 129611 129631 +20
Branches 23580 23580
==================================================
+ Hits 89630 89645 +15
- Misses 31943 31948 +5
Partials 8038 8038
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2719?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...g/apache/groovy/parser/antlr4/GroovyLangLexer.java](https://app.codecov.io/gh/apache/groovy/pull/2719?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FGroovyLangLexer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0dyb292eUxhbmdMZXhlci5qYXZh)
| `80.0000% <76.1905%> (-6.6667%)` | :arrow_down: |
... and [6 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/2719/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 GString syntax error when '$' is not followed by a valid interpolation
> ------------------------------------------------------------------------------
>
> Key: GROOVY-12171
> URL: https://issues.apache.org/jira/browse/GROOVY-12171
> Project: Groovy
> Issue Type: Improvement
> Reporter: Daniel Sun
> Priority: Major
>
> h3. Problem
> When a double-quoted or triple-double-quoted GString places an illegal
> character immediately after {{$}} (most commonly a trailing bare dollar
> before the closing quote), the Antlr4 lexer reports a generic *token
> recognition error* at that character and never mentions the dollar. The caret
> location is often correct, but the message is hard to understand compared
> with Groovy 2, which reported {*}illegal string body character after dollar
> sign{*}.
> Typical mistakes:
> * trailing bare {{$}} before the closer: {{{}"releases$"{}}},
> {{"""releases$"""}}
> * {{$}} not followed by an identifier or brace expression: {{{}"a$ b"{}}},
> {{"$"}}
> * EOF or newline immediately after {{$}} in an unclosed GString: {{"hello$}}
> Valid programs are unaffected ({{{}$name{}}}, brace expressions, and {{\$}}
> for a literal dollar already work).
> h3. Examples (before)
> * Source:
> {noformat}
> def Target = "releases$"
> {noformat}
> Report:
> {noformat}
> token recognition error at: '"' @ line 1, column 24.
> def Target = "releases$"
> ^
> {noformat}
> * Source:
> {noformat}
> def Target = """releases$"""
> {noformat}
> Report: *token recognition error at: '"'* at the first character of the
> closing {{"""}} (no mention of {{{}${}}})
> * Source:
> {noformat}
> def x = "a$ b"
> {noformat}
> Report: *token recognition error at: ' '* (no mention of {{{}${}}})
> h3. Root cause
> After {{GStringBegin}} / {{GStringPart}} consumes {{{}${}}}, the lexer enters
> {{GSTRING_TYPE_SELECTOR_MODE}} and expects either an opening brace or an
> identifier. Any other character raises {{{}LexerNoViableAltException{}}}.
> Default Antlr recovery surfaces that as *token recognition error at: '…'*
> with no GString-specific wording.
> A related edge case: when {{$}} is the last character of the input, Antlr
> sets {{_hitEOF}} after the begin/part token and the next {{nextToken()}}
> emits EOF without ever matching in the selector mode, so the failure becomes
> a generic unexpected-EOF parse error instead of a dollar-body diagnostic.
> h3. Goal
> Restore a clear, Groovy 2–style diagnostic — *Illegal string body character
> after dollar sign* — with an accurate caret, and name the offending character
> when one is available. Prefer a dedicated {{GroovySyntaxError}} on the lexer
> path so the parser does not fall back to an opaque exception or a useless
> SLL→LL retry for this case.
> h3. Approach
> Localised handling in {{GroovyLangLexer}} only (no grammar / public API
> change):
> * In {{{}GSTRING_TYPE_SELECTOR_MODE{}}}, override {{notifyListeners}} /
> {{recover}} for {{LexerNoViableAltException}} to emit the dedicated
> dollar-body message (append the illegal character via {{getCharErrorDisplay}}
> when not EOF).
> * Override {{nextToken}} so that EOF while still in the selector mode
> reports the same message instead of a bare unexpected-EOF parse failure.
> * Throw {{GroovySyntaxError}} with source {{LEXER}} so {{AstBuilder}} treats
> it as a fatal lexical error with line/column.
> h3. Expected result (after)
> * Source:
> {noformat}
> def Target = "releases$"
> {noformat}
> Expected:
> {noformat}
> Illegal string body character after dollar sign: '"' @ line 1, column 24.
> def Target = "releases$"
> ^
> {noformat}
> * Source:
> {noformat}
> def Target = """releases$"""
> {noformat}
> Expected: *Illegal string body character after dollar sign: '"'* at the first
> closing quote character
> * Source:
> {noformat}
> def x = "a$ b"
> {noformat}
> Expected: *Illegal string body character after dollar sign: ' '* at the space
> after {{$}}
> * Source (EOF immediately after {{{}${}}}):
> {noformat}
> def x = "hello$
> {noformat}
> Expected: *Illegal string body character after dollar sign* (no character
> suffix) at end of input
> Legal cases must keep compiling:
> {noformat}
> def Target = "releases\$"
> assert Target == 'releases$'
> def name = 'world'
> assert "hello $name" == 'hello world'
> assert "hello ${name}" == 'hello world'
> {noformat}
> h3. Compatibility and performance
> * No grammar, bytecode, or public API changes — valid GStrings parse and run
> as before.
> * Extra work runs only on the failing lexical path (mode check + message
> build); successful lexing is unchanged aside from a cheap mode check when
> emitting EOF.
> *
--
This message was sent by Atlassian Jira
(v8.20.10#820010)