You might want to try Script -> Inspect CST. Currently the parser doesn't
see the ternary operator at all. Currently, "2?[3]" is seen as a valid term
for safe indexing even though we know as humans that "2" is just a literal
and wouldn't be allowed here.
Currently, you can use "1>2?([3] as Set):null" to get around the problem. I
don't know if Daniel has some further suggestions. He had some changes in
this area in mind but I am not sure they help here.

I'd suggest creating an issue for this. We might be able to improve Groovy
or if not we should assess whether the current doco around safe indexing
explains possible interactions well enough.

Cheers, Paul.


On Sat, May 16, 2020 at 3:08 AM o...@ocs.cz <o...@ocs.cz> wrote:

> Hi there,
>
> lately, I have upgraded to Groovy 3.0.3 from 2.4.17, and have found
> expressions like this one:
>
> 1>2?[3] as Set:null
>
> which used to be parsed properly by Groovy 2 do not work anymore. It can
> be fixed by enclosing the [3] as Set into parentheses, but of course it's a
> bit at the inconvenient side, given the number of sources I build my
> application from.
>
> Did I miss some intentional breaking change, or is it a parser bug?
>
> Thanks,
> OC
>
>

Reply via email to