nau / jscala

Scala macro that produces JavaScript from Scala code.
MIT License
205 stars 25 forks source link

Iteration over `Array[Int]` causes `MatchError` in macro #9

Closed mattpap closed 11 years ago

mattpap commented 11 years ago
scala> javascript { val l = Array("1"); for (x <- l) { console.log(x); } }.asString
res18: String = 
{
  var l = ["1"];
  for (x in l) console.log(x);
}

scala> javascript { val l = Array(1); for (x <- l) { console.log(x); } }.asString
<console>:11: error: exception during macro expansion: 
scala.MatchError: scala.this.Predef.intArrayOps(l).foreach[Unit] (of class scala.reflect.internal.Trees$TypeApply)

but you can iterate over Array[Array[Int]]:

scala> javascript { val l = Array(Array(1)); for (x <- l) { console.log(x); } }.asString
res20: String = 
{
  var l = [[1]];
  for (x in l) console.log(x);
}