mirror of
https://github.com/golang/go
synced 2024-11-11 18:21:40 -07:00
cmd/compile: do not set type for OTYPESW
Same as CL 294031, but for OTYPESW. Updates #43311 Change-Id: I996f5938835baff1d830c17ed75652315106bdfd Reviewed-on: https://go-review.googlesource.com/c/go/+/298712 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
80098ef00c
commit
51d8d351c1
@ -876,7 +876,7 @@ func typecheck1(n ir.Node, top int) ir.Node {
|
||||
case ir.OTYPESW:
|
||||
n := n.(*ir.TypeSwitchGuard)
|
||||
base.Errorf("use of .(type) outside type switch")
|
||||
n.SetType(nil)
|
||||
n.SetDiag(true)
|
||||
return n
|
||||
|
||||
case ir.ODCLFUNC:
|
||||
|
@ -1,4 +1,4 @@
|
||||
// errorcheck
|
||||
// errorcheck -d=panic
|
||||
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
@ -10,7 +10,7 @@
|
||||
package p
|
||||
|
||||
func f(i interface{}) {
|
||||
if x, ok := i.(type); ok { // ERROR "outside type switch"
|
||||
if x, ok := i.(type); ok { // ERROR "assignment mismatch|outside type switch"
|
||||
_ = x
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user