Skip to content

Error message "No ClassTag available for T" not helpful on what to do to fix it and has no reflect.ClassTag to show where it is #24506

@bjornregnell

Description

@bjornregnell

Compiler version

3.7.4

Minimized example

def test[T](a: T) = collection.immutable.ArraySeq.fill(1)(a)

Output Error/Warning message

-- [E172] Type Error: -------------------------------------------------------------
1 |def test[T](a: T) = collection.immutable.ArraySeq.fill(1)(a)
  |                                                            ^
  |                                                  No ClassTag available for T
1 error found

Why this Error/Warning was not helpful

The message was unhelpful because it does not say precisely what to do to make it compile. If I have no clue about what a ClassTag is and why it's needed, then the message could be more helpful.

Suggested improvement

It could be made more helpful by showing an example of how to rewrite the type param with a context bound and include reflect.ClassTag so users do not stumble on "ClassTagf" not found in yet another error message, and not knowing in what package ClassTag resides.

For example:

-- [E172] Type Error: -------------------------------------------------------------
1 |def test[T](a: T) = collection.immutable.ArraySeq.fill(1)(a)
  |                                                            ^
  |                                            No reflect.ClassTag available for T
  | You can fix this by changing [T] to [T: reflect.ClassTag]
1 error found

Metadata

Metadata

Assignees

No one assigned

    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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions