Skip to content

"No given instance" shadows more fundamental error: "Missing type parameter" #18255

@Sporarum

Description

@Sporarum

Compiler version

3.3.0 / 3.3.1-RC1

Minimized code & Output

With as header

trait TypeClass[A]

def test1[T] = ()
def test2[T](using T) = ()

We have

test2[TypeClass] // error: No given instance of type Playground.TypeClass was found for parameter x$1 of method test2 in object Playground

If we try to introduce such an instance, it fails (as it should):

given TypeClass = ??? // Missing type parameter for Playground.TypeClass

If we use a method which does not do implicit search, it also fails, with the same error (as it should):

test1[TypeClass] // Missing type parameter for Playground.TypeClass

https://scastie.scala-lang.org/U4mVAQmXSgevhLwAyGm0tQ

Expectation

The error displayed should be Missing type parameter for Playground.TypeClass, as this hints at the correct fix: calling it with a type parameter

On a more philosophical note, I find it disturbing we do implicit search for ill-formed types, best case scenario, they fail, and as we've seen above it leads to misleading errors, but what if they succeed ?

Issues which center around error messages are usually well suited for Sprees, which is why I'll tag it as such

(It's debatable if this is really a bug, I deem it as such because of the second reason above)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions