Skip to content

Commit 51d8d35

Browse files
committed
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 <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 80098ef commit 51d8d35

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/cmd/compile/internal/typecheck/typecheck.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ func typecheck1(n ir.Node, top int) ir.Node {
876876
case ir.OTYPESW:
877877
n := n.(*ir.TypeSwitchGuard)
878878
base.Errorf("use of .(type) outside type switch")
879-
n.SetType(nil)
879+
n.SetDiag(true)
880880
return n
881881

882882
case ir.ODCLFUNC:

test/fixedbugs/issue24470.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// errorcheck
1+
// errorcheck -d=panic
22

33
// Copyright 2018 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style
@@ -10,7 +10,7 @@
1010
package p
1111

1212
func f(i interface{}) {
13-
if x, ok := i.(type); ok { // ERROR "outside type switch"
13+
if x, ok := i.(type); ok { // ERROR "assignment mismatch|outside type switch"
1414
_ = x
1515
}
1616
}

0 commit comments

Comments
 (0)