Best to open a new Jira ticket for this.  There were a number of scenarios that 
had to be handled for safe-indexing versus ternary expression.  Looks like 
there are still some out there.

Here is one example: https://issues.apache.org/jira/browse/GROOVY-9561

https://issues.apache.org/jira/projects/GROOVY/issues

From: Christopher Smith <chry...@gmail.com>
Sent: Thursday, September 8, 2022 8:39 AM
To: dev@groovy.apache.org
Subject: [EXT] Re: Groovy 4 parser bug?

External Email: Use caution with links and attachments.

The parser seems to be interpreting what you mean as a ternary as a null-safe 
array index.

On Thu, Sep 8, 2022, 08:37 o...@ocs.cz<mailto:o...@ocs.cz> 
<o...@ocs.cz<mailto:o...@ocs.cz>> wrote:
Hi there,

I've just decided it's time to upgrade from Groovy 3 to Groovy 4... and 
immediately bumped into a problem, which looks like a parser bug in an 
extremely trivial scenario, which seems weird.

Do I perhaps miss something? I've checked 
https://groovy-lang.org/releasenotes/groovy-4.0.html#Groovy4.0-breaking<https://urldefense.com/v3/__https:/groovy-lang.org/releasenotes/groovy-4.0.html*Groovy4.0-breaking__;Iw!!GFN0sa3rsbfR8OLyAw!coZUfpDQb6wM7aQnB_qs22qgQ4Ua8PmHNoa6nVvXRqumFKTpcTU_ldwb5oy5T8UjVyNMjcdzN8FMNqOOlfcoBA$>,
 but in vain :(

===
2012 ocs /tmp> <q.groovy
def p
def x=p?[0]:[1]
println "got $x"
2013 ocs /tmp> /usr/local/groovy-3.0.12/bin/groovy q
got [1]
2014 ocs /tmp> /usr/local/groovy-4.0.4/bin/groovy q
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/private/tmp/q.groovy: 2: Unexpected input: ':' @ line 2, column 12.
   def x=p?[0]:[1]
              ^

1 error

2015 ocs /tmp>
===

Thanks for any insight,
OC

Reply via email to