Skip to content

Type errors should evaluate type matches with known arguments #22333

Closed
@belamenso

Description

@belamenso

Compiler version

3.6.2

Minimized example

import scala.Tuple

class Container[Rs <: Tuple] {
  def guard(a: Tuple.Tail[Rs]): Unit = ()
}

@main def main(): Unit =
  Container[(1,2,3)].guard((5, 6, 8))

Output Error message

[error] -- [E007] Type Mismatch Error: Main.scala:8:27 
[error] 8 |  Container[(1,2,3)].guard((5, 6, 8))
[error]   |                           ^^^^^^^^^
[error]   |                   Found:    (Int, Int, Int)
[error]   |                   Required: Tuple.Tail[((1 : Int), (2 : Int), (3 : Int))]
[error]   |
[error]   | longer explanation available when compiling with `-explain`
[error] one error found

Why this Error/Warning was not helpful

The message was unhelpful because it contains unevaluated type matches (Tuple.Tail) that depend on entirely known types.

Suggested improvement

It could look like

[error] 8 |  Container[(1,2,3)].guard((5, 6, 8))
[error]   |                           ^^^^^^^^^
[error]   |                   Found:    (Int, Int, Int)
[error]   |                   Required: ((2 : Int), (3 : Int))

Metadata

Metadata

Assignees

Labels

area:reportingError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions