Closed
Description
Compiler version
Scala 3.3.0
Minimized code & Output
def foo(x: Int) = 0
foo(x => x) // error:
// Missing parameter type
// I could not infer the type of the parameter x.
https://scastie.scala-lang.org/Te6OUPEKTnmMn304qWsPew
Expectation
The fact the inference fails hides a more essential issue:
There is no type such that this succeeds.
(Except if there are implicit conversions, with the following, inferring Int
would work:
given Conversion[Int => Int, Int] = f => f(42)
)
Even considering this point, a better error would be something like:
Found: T1 => T1
Expected: Int
Where T1 could not be inferred
It displays more information, naturally leading the user to realize x => x
would not work in any case