effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Attempting to invoke a method on an unboxed object yields confusing error message

Open phischu opened this issue 6 months ago • 0 comments

Consider the following program:

interface Stream[A] {
  def head(): A
  def tail(): Stream[A] at {}
}

def main() = {
  def ones = new Stream[Int] {
    def head() = 1
    def tail() = ones
  }
  val rest: Stream[Int] at {} = ones.tail()
  println(rest.head())
}

It marks the invocation rest.head() and gives me the following error:

Cannot typecheck call.
There are multiple overloads, which all fail to check:

Possible overload: effekt::println of type String => Unit
  Cannot find type for head -- forward uses and recursive functions need annotated return types.

...

Ideally, this program would just be accepted and the implicit unbox inserted around rest. Even better, ones.tail().tail().head() should be accepted as well.

phischu avatar Jun 18 '25 07:06 phischu