You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (Jira)" <ji...@apache.org> on 2021/06/24 15:56:00 UTC

[jira] [Resolved] (GROOVY-10146) Groovy 3 compilation errors are less accurate than Groovy 2

     [ https://issues.apache.org/jira/browse/GROOVY-10146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Sun resolved GROOVY-10146.
---------------------------------
    Fix Version/s: 3.0.9
                   4.0.0-beta-1
         Assignee: Daniel Sun
       Resolution: Fixed

> Groovy 3 compilation errors are less accurate than Groovy 2
> -----------------------------------------------------------
>
>                 Key: GROOVY-10146
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10146
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Compiler
>    Affects Versions: 3.0.7, 3.0.8
>            Reporter: Sterling Greene
>            Assignee: Daniel Sun
>            Priority: Minor
>             Fix For: 4.0.0-beta-1, 3.0.9
>
>
> Given this broken bit of Groovy code (note the missing single quote after Hello):
> {code:groovy}
> class Foo {
>     void bar(Closure c) {
>         c.call()
>     }
> }
> def foo = new Foo()
> foo.bar {
>     println 'Hello
> }
> {code}
> In Groovy 2.5.11, the compiler generates a message like:
> {quote}expecting ''', found '\n' at line: 10, column: 19{quote}
> In Groovy 3.0.8, the compiler generates a message like:
> {quote}Unexpected input: '{' at line: 9, column: 9{quote}
> The Groovy 2.x message has identified the right problem (a missing single quote), while the Groovy 3.x message is unrelated to the syntax error. 
> We see this in Gradle build scripts too. In this broken Gradle script (again, a missing single quote):
> {code}
> dependencies {
>     testImplementation group: 'junit', name: 'junit', version: '4.12
> }
> {code}
> In Gradle <7 (which uses Groovy 2), the compilation failure says:
> {quote}expecting ''', found '\n' @ line 13, column 69.
>       name: 'junit', version: '4.12{quote}
> But in Gradle 7+ (which uses Groovy 3), the compilation failure says:
> {quote}Unexpected input: '{' @ line 12, column 14.
>      dependencies {{quote}
> I assume this effects all Groovy 3.x versions, but I only tried 3.0.7 and 3.0.8. I also assume the better behavior is the same for all Groovy 2.x, but I didn't try any other version.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)