On Sun, 4 May 2014, Chris Cannam wrote:
> Primitive array casts again:
>
>> x = [[1],[2],[3]] as ~float[][]
> x is float[][] = [[F@11e3c55,[F@b1b14,[F@11ef262]
>> map list x
> java.lang.NullPointerException
> at yeti.lang.compiler.JavaType.isSafeCast(JavaType.java:751)
> at yeti.lang.compiler.YetiAnalyzer.apply(YetiAnalyzer.java:497)
> at
> yeti.lang.compiler.YetiAnalyzer.analyze(YetiAnalyzer.java:171)
> at
> yeti.lang.compiler.YetiAnalyzer.toCode(YetiAnalyzer.java:1604)
> at yeti.lang.compiler.Compiler.compile(Compiler.java:473)
> etc
Should be fixed now. This example gives type error now (allowing it
would be more work).
>> map do i: list x[i] done [0..length x]
This works with range [0..length x - 1].
>> map do i: list x[i] done [0..2]
> [[1.0],[2.0],[3.0]] is list<list<number>>
Alternative would be:
> flip map (list x) (as list<number>)
[[1.0],[2.0],[3.0]] is list<list<number>>
The flip is used to reverse the map arguments, making it easier for type
inferencer to work out the as cast type.