Skip to content

go/types, types2: error messages don't distinguish between different types with the same names #48295

@griesemer

Description

@griesemer
package p

type T int

func _() {
	type GlobalT = T
	type T int
	var _ T = GlobalT(0)
}

produces:

x.go:8:12: incompatible type: cannot use GlobalT(0) (constant 0 of type T) as T value

The error message reports the same type (T) for the variable and the constant, which is confusing.

Maybe we can detect cases like these and provide additional information, such as where the types are declared.

Not urgent as this is a rare scenario.

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions