Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.0.7, 3.0.8
-
None
Description
Given this broken bit of Groovy code (note the missing single quote after Hello):
class Foo { void bar(Closure c) { c.call() } } def foo = new Foo() foo.bar { println 'Hello }
In Groovy 2.5.11, the compiler generates a message like:
expecting ''', found '\n' at line: 10, column: 19
In Groovy 3.0.8, the compiler generates a message like:
Unexpected input: '{' at line: 9, column: 9
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):
dependencies { testImplementation group: 'junit', name: 'junit', version: '4.12 }
In Gradle <7 (which uses Groovy 2), the compilation failure says:
expecting ''', found '\n' @ line 13, column 69.
name: 'junit', version: '4.12
But in Gradle 7+ (which uses Groovy 3), the compilation failure says:
Unexpected input: '{' @ line 12, column 14.
dependencies {
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.