golang/go

go/types: allows multiple-value in switch and case

dvyukov opened this issue · 1 comments

gotype successfully compiles the following program:

package n

func f() (int, int) {
    return 0, 0
}

func g() {
    switch f() {
    default:
    //case f():
    }
}

gc says:

go.go:8: multiple-value f() in single-value context

which looks like the right thing.

Also if you uncomment the case, gotype says:

go.go:10:7: cannot compare f() == f() (operator == not defined for (int, int))

gotype should reject f() in switch case at earlier stage and say something along the lines of the gc error message (the issue is not with comparison, it is with multiple-value in single-value context).

on commit af81789

CL https://golang.org/cl/12713 mentions this issue.