You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Sean Fitts (Jira)" <ji...@apache.org> on 2021/03/05 20:34:00 UTC
[jira] [Created] (GROOVY-9969) Use of a negative range with Long
values results in reversed sequence
Sean Fitts created GROOVY-9969:
----------------------------------
Summary: Use of a negative range with Long values results in reversed sequence
Key: GROOVY-9969
URL: https://issues.apache.org/jira/browse/GROOVY-9969
Project: Groovy
Issue Type: Bug
Components: groovy-runtime
Affects Versions: 2.5.14, 2.5.12
Reporter: Sean Fitts
Use of long values when describing an array range results in a reserved result when it should not.
For example, the following is true in 2.5.11 and false starting in 2.5.12:
{code:java}
[1L, 2L, 3L, 4L, 5L, 6L][(2L .. -2L)] == [3L, 4L, 5L]
{code}
The following however is true in all versions of 2.5:
{code:java}
[1L, 2L, 3L, 4L, 5L, 6L][(2 .. -2)] == [3L, 4L, 5L]
{code}
I believe this bug was introduced in the fix for https://issues.apache.org/jira/browse/GROOVY-8966. The NumberRange produced reverses the from and to resulting in the reversed sequence.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)