You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/06/19 11:46:00 UTC
[jira] [Updated] (GROOVY-9969) Use of a negative range with Long values results in reversed sequence
[ https://issues.apache.org/jira/browse/GROOVY-9969?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-9969:
------------------------------
Description:
Use of long values when describing an array range results in a reversed 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.
was:
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.
> 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.12, 2.5.14
> Reporter: Sean Fitts
> Priority: Minor
>
> Use of long values when describing an array range results in a reversed 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.20.10#820010)