Skip to content

Misleading error message with default given parameter #14842

Closed
@kpodsiad

Description

@kpodsiad

Compiler version

3.1.1

Minimized code

//> using scala "3.1.1"

class Dummy
object Dummy:
  val empty = new Dummy

sealed trait Node:
  def as[T](using d: Dummy = Dummy.empty): Either[String, T] = ???

object Sample extends App {
  val node: Node = ???

  val x: Either[Int, Any] = node.as[Any]
}

Output

Compiling project (Scala 3.1.1, JVM)
[error] ./Sample.scala:13:41: no implicit argument of type Dummy was found for parameter d of method as in trait Node
[error]   val x: Either[Int, Any] = node.as[Any]
[error]                                         ^
Error compiling project (Scala 3.1.1, JVM)                 

Expectation

The error message is misleading, something like: Found Either[String, Any], required Either[Int, Any] will be more adequate.

Metadata

Metadata

Assignees

Labels

area:reportingError reporting including formatting, implicit suggestions, etcitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions