[ 
https://issues.apache.org/jira/browse/GROOVY-12625?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King resolved GROOVY-12625.
--------------------------------
    Fix Version/s: 7.0.0-alpha-1
                   6.0.1
         Assignee: Paul King
       Resolution: Fixed

> SC fails with ArrayIndexOutOfBoundsException for ++ or -- on a subscript 
> whose element type is not a primitive or wrapper number type
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12625
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12625
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.33, 5.0.8, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 7.0.0-alpha-1, 6.0.1
>
>
> {code:groovy}
> @groovy.transform.CompileStatic
> def f() {
>     List<BigDecimal> l = [1.0]
>     l[0]++
>     l
> }
> assert f() == [2.0]
> {code}
> Actual: compilation fails with "General error during instruction selection: 
> Index 1 out of bounds for length 1" (ArrayIndexOutOfBoundsException in 
> StaticInvocationWriter.loadArguments). The same happens for prefix and 
> postfix ++ and -- on a BigDecimal array, a map of BigDecimal values, a list 
> of BigInteger, String, Character, char[], and a class with getAt/putAt 
> returning BigDecimal.
> Expected: the code compiles and the assertion passes, as it does without the 
> annotation and with @TypeChecked.
> The type checker resolves next() or previous() by passing the subscript 
> expression to findMethodOrFail. StaticCompilationVisitor then stores next() 
> as that expression's binary target, replacing getAt, so l[0] is compiled as a 
> call to next with argument 0.
> Seen in 4.0.33, 5.0.8 and 6.0.0.
> PR: https://github.com/apache/groovy/pull/3151



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to