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

x/tools/gopls: break in type switch highlights outer for loop #65752

Closed
dominikh opened this issue Feb 16, 2024 · 3 comments
Closed

x/tools/gopls: break in type switch highlights outer for loop #65752

dominikh opened this issue Feb 16, 2024 · 3 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@dominikh
Copy link
Member

dominikh commented Feb 16, 2024

gopls version

golang.org/x/tools/gopls@(devel)

What did you do?

Input file:

package main

func main() {
	var x any
	for {
		switch x.(type) {
		default:
			break
		}
	}
}

CLI invocation:

$ ~/prj/bin/gopls highlight ./bar.go:8:5
Log: Loading packages...
Info: Finished loading packages.
/home/dominikh/prj/src/example.com/bar.go:5:2-5
/home/dominikh/prj/src/example.com/bar.go:8:4-9

What did you see happen?

bar.go:5:2-5 corresponds to the for keyword.

What did you expect to see?

The break statement breaks from the switch statement, not the for loop. Gopls does handle this correctly for value switches, but not for type switches.

Editor and settings

No response

Logs

No response

@dominikh dominikh added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Feb 16, 2024
@gopherbot gopherbot added this to the Unreleased milestone Feb 16, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.16.0 Feb 16, 2024
@findleyr
Copy link
Contributor

Thanks for reporting.

@adonovan adonovan self-assigned this Feb 16, 2024
@gopherbot
Copy link

Change https://go.dev/cl/564955 mentions this issue: gopls/internal/golang: highlight typeswitc break correctly

@gopherbot
Copy link

Change https://go.dev/cl/564955 mentions this issue: gopls/internal/golang: highlight typeswitch break correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants