Skip to content

go/types: provide better error message for errors in n:1 init assignment #15783

@griesemer

Description

@griesemer

Given a.go:

package p

var a, b []int = f1() // error

func f1() (_ []int, _ int) {
    return
}

gotype reports:

$ gotype a.go
a.go:3:18: cannot use f1() (value of type int) as []int value in assignment

vs gc compiler:

$ go tool compile a.go
a.go:3: cannot assign int to b (type []int) in multiple assignment

The gc compiler's error message is much better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions