Scalaxy loops don't work inside partially-evaluated curried thunk-taking functions
lihaoyi opened this issue · comments
This refuses to compile:
def apple[R](f: () => R)() = f()
val x = apple( () =>
for(i <- (1 until 10).optimized)()
) _
type parameter not specified
for(i <- (1 until a.length).optimized)()
^
But this works (not optimizing)
def apple[R](f: () => R)() = f()
val x = apple( () =>
for(i <- (1 until 10))()
) _
and so does this (not partially evaluated)
def apple[R](f: () => R)() = f()
val x = apple( () =>
for(i <- (1 until 10).optimized)()
)()
I'm not familiar enough with how macros work to provide a fix, but it seems like a bug to me.
Hi @lihaoyi ,
Thanks for your report!
It looks like your code snippets compiles fine with Scala 2.10.2 and 2.10.1, but fails with 2.10.0. It's probably just one of the many bugs fixed in 2.10.1 and 2.10.2. I'll investigate but in the meantime I would strongly encourage you to upgrade :-)
Cheers
Good to know; I'll try upgrading and see how it works. Thanks =)
I'm calling it fixed because it seems to work now with 2.10.4