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
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ALTree
Copy link
Member

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 Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 7, 2022
@ALTree ALTree added this to the Go1.19 milestone Mar 7, 2022
@griesemer
Copy link
Contributor

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 The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Mar 7, 2022
@griesemer griesemer self-assigned this Mar 7, 2022
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants