You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2026/04/18 14:08:00 UTC
[jira] [Updated] (GROOVY-10755) Ternary returning a list gets parsed improperly
[ https://issues.apache.org/jira/browse/GROOVY-10755?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-10755:
---------------------------------
Priority: Major (was: Minor)
> Ternary returning a list gets parsed improperly
> -----------------------------------------------
>
> Key: GROOVY-10755
> URL: https://issues.apache.org/jira/browse/GROOVY-10755
> Project: Groovy
> Issue Type: Bug
> Components: parser, parser-antlr4
> Affects Versions: 4.0.4
> Reporter: OC
> Assignee: Eric Milles
> Priority: Major
>
> Another problem with ternary operator, this time almost surely a clash with the safe index operator:
> {code:java}
> 2034 ocs /tmp> >q.groovy
> 1>2?[1]:0
> 2035 ocs /tmp> /usr/local/groovy-4.0.4/bin/groovy q
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> /private/tmp/q.groovy: 1: Unexpected input: ':' @ line 1, column 8.
> 1>2?[1]:0
> ^
> 1 error
> 2036 ocs /tmp>
> {code}
> Most probably affects 4 from the beginning. Used to work properly in previous versions (including Groovy 3 which supported the safe index operator all right).
> The issue can be fixed easily e.g. inserting a space betwixt ? and [, thus the minor priority. Nevertheless it is somewhat inconvenient since the operation is pretty common and frequently occurs in the current codebase, which worked under 3 all right. Also, it is sort of difficult to solve it (semi-)automatically, for it is not entirely trivial to distinguish real safe indices from ternaries automatically without a full-fledged parser :(
--
This message was sent by Atlassian Jira
(v8.20.10#820010)