Skip to content
Permalink
Browse files

fix var/laziness bug in Foldable[List]

  • Loading branch information
tonymorris committed Apr 3, 2012
1 parent 2b7faa1 commit 48c29e13afbe165700ce860decf9aa50b0e5f52d
Showing with 5 additions and 1 deletion.
  1. +5 −1 core/src/main/scala/scalaz/std/List.scala
@@ -64,7 +64,11 @@ trait ListInstances extends ListInstances0 {
val s = new ArrayStack[A]
fa.foreach(a => s += a)
var r = z
while (!s.isEmpty) {r = f(s.pop, r)}
while (!s.isEmpty) {
// force and copy the value of r to ensure correctness
val w = r
r = f(s.pop, w)
}
r
}

0 comments on commit 48c29e1

Please sign in to comment.