Skip to content

cmd/compile: confusing error messages when package paths mismatch #16133

@rogpeppe

Description

@rogpeppe

Example error message:

./fakeapi_test.go:29: cannot use names.NewModelTag("dead-beef") (type names.ModelTag) as type names.ModelTag in field value

The error was actually that I'd imported the names package from the wrong path.
It would be nice if the error message could make that clearer - as it is, it
it confusing because both types look identical.

For example:

./fakeapi_test.go:29: cannot use names.NewModelTag("dead-beef") (type names.ModelTag) as type names.ModelTag in field value (package github.com/juju/names, not gopkg.in/juju/names.v2)

Another possibility might be to do general disambiguation when more than one
identical package name referring to a different path is used in the same error
message.

For example:

./fakeapi_test.go:52: cannot use "github.com/juju/names".NewModelTag("dead-beef") (type "github.com/juju/names".ModelTag) as type "gopkg.in/juju/names.v2".ModelTag in field value

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions