This has been reported under a few different guises. There are some other 
tickets for ranges and negative indexes.

https://issues.apache.org/jira/browse/GROOVY-6193
https://issues.apache.org/jira/browse/GROOVY-4652
https://issues.apache.org/jira/browse/GROOVY-1740
https://issues.apache.org/jira/browse/GROOVY-1286


-----Original Message-----
From: o...@ocs.cz <o...@ocs.cz> 
Sent: Monday, September 19, 2022 2:45 PM
To: Groovy_Developers <dev@groovy.apache.org>
Subject: [EXT] indexing inconsistecy: bug or intentional?

External Email: Use caution with links and attachments.

Hi there,

is this behaviour intentional? Seems to me it should either throw in all these 
cases, or in none of them, but as always, I might be missing something of 
importance:

===
Groovy Shell (4.0.5, JVM: 1.8.0_181)
Type ':help' or ':h' for help.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
groovy:000> [][0]
===> null
groovy:000> [][666]
===> null
groovy:000> [][1e9]
===> null
groovy:000> [][-1]
ERROR java.lang.ArrayIndexOutOfBoundsException:
Negative array index [-1] too large for array size 0 groovy:000> [][-3] ERROR 
java.lang.ArrayIndexOutOfBoundsException:
Negative array index [-3] too large for array size 0 groovy:000> ===

Thanks and all the best,
OC

Reply via email to