google-code-export / nativelibs4java

Automatically exported from code.google.com/p/nativelibs4java
1 stars 1 forks source link

[ScalaCLPlugin] NullPointerException at Array[(T1, T2)].foreach in 0.2.Beta2 #40

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
ScalaCL Optimizer failed to transform "for ((i, j) <- Array(1 -> 1, 2 -> 2))".
Similar expressions ("Array(1->1, 2->2).foreach", "for ((i, j) <- List..." and 
"for (ij <- Array...") are OK.

% env SCALACL_TRACE=1 SCALACL_VERBOSE=1 scala

scala> for ((i, j) <- Array(1 -> 1, 2 -> 2)) println(i, j)
[scalacl] <console>:6 transformed Array[(T1, T2)].filter into equivalent while 
loop.
[scalacl] <console>:6 transformed Array[(T1, T2)].foreach into equivalent while 
loop.
java.lang.NullPointerException
    at scala.collection.mutable.ArrayBuilder$ofRef.mkArray(ArrayBuilder.scala:51)
    at scala.collection.mutable.ArrayBuilder$ofRef.resize(ArrayBuilder.scala:57)
    at scala.collection.mutable.ArrayBuilder$ofRef.ensureSize(ArrayBuilder.scala:69)
    at scala.collection.mutable.ArrayBuilder$ofRef.$plus$eq(ArrayBuilder.scala:74)
    at .<init>(<console>:6)
    at .<clinit>(<console>)
    at RequestResult$.<init>(<console>:9)
    at RequestResult$.<clinit>(<console>)
    at RequestResult$scala_repl_result(<console>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(...

scala> for ((i, j) <- List(1 -> 1, 2 -> 2)) println(i, j) 
[scalacl] <console>:6 transformed List[(T1, T2)].filter into equivalent while 
loop.
(1,1)
(2,2)

scala> Array(1->1, 2->2).foreach { case (i, j) => println(i, j) }  
[scalacl] <console>:6 transformed Array[(T1, T2)].foreach into equivalent while 
loop.
(1,1)
(2,2)

> What version of the product are you using? On what operating system?

-rw-r--r-- 1 mar 1294787 2011-01-15 21:41 lib/scalacl-0.2.Beta2-shaded.jar
-rw-r--r-- 1 mar  574394 2011-01-15 21:41 
misc/scala-devel/plugins/scalacl-compiler-plugin-0.2.Beta2.jar

Scala 2.8.1.final, Java 1.6.0_21, Ubuntu 10.04 (kernel 2.6.32 x86_64)

Original issue reported on code.google.com by natsumar...@gmail.com on 15 Jan 2011 at 4:32

GoogleCodeExporter commented 9 years ago
Hello,

Thanks a lot for your report !
The NullPointerException actually happens during execution, not during 
compilation, so it seems that the compiler plugin produces invalid code... will 
fix this ASAP :-)

Cheers
--
Olivier

Original comment by olivier.chafik@gmail.com on 15 Jan 2011 at 6:36

GoogleCodeExporter commented 9 years ago
Fixed by revision #1571 in version 0.2.Beta3 (sbaz) and latest Maven 
0.2-SNAPSHOT.

Thanks again for your report,
Cheers
--
Olivier

Original comment by olivier.chafik@gmail.com on 16 Jan 2011 at 1:01