Java exception when assigning to primitive array element

3 views
Skip to first unread message

Chris Cannam

unread,
Dec 12, 2012, 5:12:39 PM12/12/12
to yeti-lang
> arr = array[1..10]
arr is array<number> = [1,2,3,4,5,6,7,8,9,10]
> p_arr = new double[10]
p_arr is double[] = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
> for [0..9] do i: p_arr[i] := arr[i] done
java.lang.VerifyError: (class: code$, method: apply signature:
(Ljava/lang/Object;)Ljava/lang/Object;) Incompatible object argument
for function call
at code.apply(<>)
at yeti.lang.compiler.eval._1(eval.yeti:85)
at yeti.lang.compiler.eval.execClass(eval.yeti:63)
at yeti.lang.compiler.eval$evaluateYetiCode$._0(eval.yeti:386)
at yeti.lang.compiler.eval$evaluateYetiCode$.apply(eval.yeti:362)
at yeti.lang.Fun2_.apply(Unknown Source)
at yeti.lang.compiler.yeti.repl(yeti.yeti:58)
at yeti.lang.compiler.yeti.main(yeti.yeti:212)

I can sort of see why this could be a problem, and the workaround is
easy at least:

> for [0..9] do i: val = arr[i]; p_arr[i] := val done
> p_arr
[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0] is double[]

but I'd still have expected the original formula to work?


Chris

Madis

unread,
Dec 12, 2012, 7:05:56 PM12/12/12
to yeti-lang

On Wed, 12 Dec 2012, Chris Cannam wrote:

>> arr = array[1..10]
> arr is array<number> = [1,2,3,4,5,6,7,8,9,10]
>> p_arr = new double[10]
> p_arr is double[] = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
>> for [0..9] do i: p_arr[i] := arr[i] done
> java.lang.VerifyError: (class: code$, method: apply signature:
> (Ljava/lang/Object;)Ljava/lang/Object;) Incompatible object argument
> for function call
> at code.apply(<>)
> at yeti.lang.compiler.eval._1(eval.yeti:85)
...
> I can sort of see why this could be a problem, and the workaround is
> easy at least:
>
>> for [0..9] do i: val = arr[i]; p_arr[i] := val done
>> p_arr
> [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0] is double[]
>
> but I'd still have expected the original formula to work?

It was a compiler bug, should be fixed now in git master (the yeti.jar
is also updated).
Reply all
Reply to author
Forward
0 new messages