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

Eric Milles reassigned GROOVY-9561:
-----------------------------------

    Assignee: Eric Milles

> Some ternary expressions with []'s and 'as' are not parsed properly
> -------------------------------------------------------------------
>
>                 Key: GROOVY-9561
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9561
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser, parser-antlr4
>    Affects Versions: 3.0.3
>            Reporter: OC
>            Assignee: Eric Milles
>            Priority: Minor
>
> Expressions of type “1>2?[3] as Set:null” are not parsed properly, example 
> below. I haven't tried all the versions, but I believe it is a problem caused 
> by the parrot; I've checked 2.4.17 and 2.5.8 and both worked properly.
> There's a very plain work-around, it suffices to enclose the middle part of 
> the expression in parentheses, like “1>2?([3] as Set):null”. Besides, such 
> expressions are pretty rare.
> Far as I understand, the ambiguity of “as” and safe indexing both play their 
> part and it might prove difficult to fix without forbidding “as” usage as 
> identifier, which would break old code in a considerably worse way than this.
> For all these reasons I believe the trivial priority in this case is better 
> than minor, which would technically fit the problem better.
>  
> {code:java}
> 52 ocs /tmp> >q.groovy                           
> 1>2?[3] as Set:null
> 53 ocs /tmp> /usr/local/groovy-3.0.3/bin/groovy q
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> /private/tmp/q.groovy: 1: Unexpected input: '1>2?[3]' @ line 1, column 1.
>    1>2?[3] as Set:null
>    ^
> 1 error
> 54 ocs /tmp> 
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to