modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue20185.go (about) 1 // errorcheck 2 3 // Copyright 2017 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Issue 20185: type switching on untyped values (e.g. nil or consts) 8 // caused an internal compiler error. 9 10 package p 11 12 func F() { 13 switch t := nil.(type) { // ERROR "cannot type switch on non-interface value nil" 14 default: 15 _ = t 16 } 17 } 18 19 const x = 1 20 21 func G() { 22 switch t := x.(type) { // ERROR "cannot type switch on non-interface value x \(type untyped number\)" 23 default: 24 } 25 }