Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: 1.18 regression in error message for fallthrough in type switch #51533

Closed
ALTree opened this issue Mar 7, 2022 · 2 comments
Closed
Labels
NeedsFix
Milestone

Comments

@ALTree
Copy link
Member

@ALTree ALTree commented Mar 7, 2022

package p

func f(i interface{}) {
	switch i.(type) {
	case int:
		println("int")
		fallthrough
	default:
		println("other")
	}
}

The 1.17 error message explains what's wrong with this program: fallthrough cannot be used in a type switch:

$ go version
go version go1.17.8 linux/amd64
$ go build test.go
./test.go:7:3: cannot fallthrough in type switch

The tip compiler, on the other hand, doesn't:

$ gotip version
go version devel go1.19-7dc6c5ec34 Mon Mar 7 18:19:44 2022 +0000 linux/amd64
$ gotip build test.go
./test.go:7:3: fallthrough statement out of place

1.18rc1 is also affected. Tentatively putting in the 1.19 milestone since it may be too late for 1.18.

cc @griesemer @findleyr

@ALTree ALTree added the NeedsInvestigation label Mar 7, 2022
@ALTree ALTree added this to the Go1.19 milestone Mar 7, 2022
@griesemer
Copy link
Contributor

@griesemer griesemer commented Mar 7, 2022

Straight-forward to fix but at this point we're just making release blocker changes. 1.19 is good.

@griesemer griesemer added NeedsFix and removed NeedsInvestigation labels Mar 7, 2022
@griesemer griesemer self-assigned this Mar 7, 2022
@gopherbot
Copy link

@gopherbot gopherbot commented Mar 14, 2022

Change https://go.dev/cl/392759 mentions this issue: go/types, types2: better error msg when using fallthrough in type switch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix
Projects
None yet
Development

No branches or pull requests

3 participants