Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
None
-
None
-
None
Description
Here is the issue reported by a Spock user:
in groovy 2.5
modification | expected { Instant i, ZoneId z -> i.plusSeconds(1) } | defaultInstant.plusSeconds(1)
these were treated as separate expressions
in groovy 3.0 the closure gets merged as argument to the expected above.
modification | this.expected({ Instant i, ZoneId z ->
i.plusSeconds(1)
}) | defaultInstant.plusSeconds(1)
I propose to unify the grammar of closure arguments:
// 2 expressions: variable and closure meth { p -> } // 2 expressions: binary expression and closure a | meth { p -> }
In the old grammar, the following code is parsed as method call with a closure argument.
meth { p -> }
Luckily, groovy-parser project containing source code of some famous groovy projects, none of which are broken because of the proposed change.
See the discussion in the dev mailing list: http://groovy.329449.n5.nabble.com/About-eliminating-ambiguities-of-method-call-with-closure-argument-tt5766830.html
Attachments
Issue Links
- is duplicated by
-
GROOVY-9494 Closure in next line continues previous expression in 3.0 but didn't in 2.5
- Open
- links to