Skip to content

go/types: type mismatch with func error less helpful since go 1.18 #73428

Open
@gnojus

Description

@gnojus

Go version

go version go1.24.2 linux/amd64

Output of go env in your module/workspace:

N/A

What did you do?

This like #57160, but with func instead of pointers:

package p

func _() {
	if foo < bar {
	}
}

func foo() {}
const bar = 0

What did you see happen?

./main.go:4:11: cannot convert bar (untyped int constant 0) to type func()

But even if you could convert it to func(), it's not comparable with <

What did you expect to see?

Like go 1.17:

./main.go:4:9: invalid operation: foo < bar (mismatched types func() int and int)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.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