[
https://issues.apache.org/jira/browse/GROOVY-10659?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Sun resolved GROOVY-10659.
---------------------------------
Fix Version/s: 5.0.0-alpha-1
3.0.12
4.0.4
Resolution: Fixed
> Parrot Parser: named arguments does not support all key expressions
> -------------------------------------------------------------------
>
> Key: GROOVY-10659
> URL: https://issues.apache.org/jira/browse/GROOVY-10659
> Project: Groovy
> Issue Type: Bug
> Components: parser-antlr4
> Reporter: Michal Ševčenko
> Assignee: Daniel Sun
> Priority: Major
> Fix For: 5.0.0-alpha-1, 3.0.12, 4.0.4
>
>
> This is IMO a regression (wrt. e.g. Groovy 2.4.11), the following does not
> compile in Groovy 3.0.10.
> {code:java}
> def fun = { arg ->
> return arg
> }
> fun (
> x: 1,
> [a: 1]: '2'
> ){code}
> This is the combination of the following:
> * map literal is used as an argument of a function, without enclosing
> brackets (I hope this is legal)
> * another map literal is used as a key of the outer map (I hope this is
> legal too)
> If both these preconditions are met, the compiler complains with:
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> index.groovy: 5: Unexpected input: '(' @ line 5, column 5.
> fun (
> ^
> 1 error {code}
> This does compile:
> {code:java}
> def fun = { arg ->
> return arg
> }
> fun (
> x: 1,
> a: '2'
> ){code}
> So does this:
> {code:java}
> def fun = { arg ->
> return arg
> }
> fun ([
> x: 1,
> [a: 1]: '2'
> ]) {code}
> Is this a bug?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)