Skip to content

Confusing error message for different types with same name #326

Open
@jiribenes

Description

@jiribenes

Trying to write a sort that works on the first element of a tuple:

import immutable/list

def comparePairsByFirst[A, B](x: Tuple2[A, B], y: Tuple2[A, B]){ compare: (A, A) => Boolean }: Boolean = {
    val (a1, b1) = x
    val (a2, b2) = y
    compare(a1, a2)
}

def sortOnFst[Int, B](lst: List[Tuple2[Int, B]]): List[Tuple2[Int, B]] = {
    lst.sortBy { (p1, p2) => 
      comparePairsByFirst(p1, p2) { 
        (a, b) => a < b 
      } 
    }
}

This is reproducible both on the website and on current master.

I got the following error message:

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

Possible overload: effekt.infixLt of type (Int, Int) => Boolean
  Expected Int but got Int.
  Expected Int but got Int.

Possible overload: effekt.infixLt$1 of type (Double, Double) => Boolean
  Expected Double but got Int.
  Expected Double but got Int.

Possible overload: effekt.infixLt$2 of type (String, String) => Boolean
  Expected String but got Int.
  Expected String but got Int.

Specifically, the very first part seems wrong:

Possible overload: effekt.infixLt of type (Int, Int) => Boolean
  Expected Int but got Int.
  Expected Int but got Int.

This overload looks like it should work in my case (I'm comparing two Ints), but it gets refused for some mysterious reason.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions