You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An implicit conversion from a function type to another fails with a funny error message when the argument is a partially-applied function. Here some code:
classFoo {
implicitdefpair2fun2[A, B, C](f: (A, B) =>C) =
{p: (A, B) => f(p._1, p._2) }
deffoo(f: ((Int, Int)) =>Int) = f
defbar(x: Int, y: Int) = x + y
foo({ (x: Int, y: Int) => x + y }) // works
foo(pair2fun2(bar)) // works
foo(bar _) // error
foo(bar) // same error
}
The errors are:
/home/iuliandragos/sandbox/views.scala:10:error: missing arguments for method bar in classFoo;
follow this method with `_' if you want to treat it as a partially applied function
foo(bar _) // error
^
/home/iuliandragos/sandbox/views.scala:11:error: missing arguments for method bar in classFoo;
follow this method with `_' if you want to treat it as a partially applied function
foo(bar) // same error
^
two errors found
The first error message is clearly confusing, as the '_' is there... This kind of conversions are very useful when writing (or using) parsing combinators. ;-)
The text was updated successfully, but these errors were encountered:
An implicit conversion from a function type to another fails with a funny error message when the argument is a partially-applied function. Here some code:
The errors are:
The first error message is clearly confusing, as the '_' is there... This kind of conversions are very useful when writing (or using) parsing combinators. ;-)
The text was updated successfully, but these errors were encountered: