Skip to content
Switch branches/tags

Latest commit

Consider the following program:

	package p

	func f() {
		x := 1
		v := 2
		switch v.(type) {
		case int:
			println(x / 0)
		case 1:

Before this CL, the compiler prints:

	x.go:4:2: x declared but not used
	x.go:6:9: v (variable of type int) is not an interface

x is in fact used, and other errors in the switch go undiagnosed.

This commit fixes that problem by processing the switch statement
even when the 'not an interface' error is reported.

Now the compiler drops the spurious 'declared but not used'
and adds two previously undiagnosed problems:

	x.go:6:9: v (variable of type int) is not an interface
	x.go:9:15: invalid operation: division by zero
	x.go:10:7: 1 is not a type

go/types was printing roughly the same thing the compiler did before,
and now still prints roughly the same thing the compiler does after.
(The only differences are in the exact reported columns.)

Fixes #50493.

Change-Id: I317883f29077b1b4bbd0e8793617fd3bb31aa0f8
Trust: Russ Cox <>
Run-TryBot: Russ Cox <>
Reviewed-by: Robert Griesemer <>
TryBot-Result: Gopher Robot <>


Failed to load latest commit information.
Latest commit message
Commit time

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.

Our canonical Git repository is located at There is a mirror of the repository at

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at

After downloading a binary release, visit for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit for source installation instructions.


Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines at

Note that the Go project uses the issue tracker for bug reports and proposals only. See for a list of places to ask questions about the Go language.