Fixes #15898.
Change-Id: I66e2ad21f283563c7142aa820f0354711d964768
Reviewed-on: https://go-review.googlesource.com/23573
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
n.Type = t
- var def *Node
+ var def, niltype *Node
for _, ncase := range n.List.Slice() {
setlineno(n)
if ncase.List.Len() == 0 {
var ptr int
switch {
case n1.Op == OLITERAL && n1.Type.IsKind(TNIL):
+ // case nil:
+ if niltype != nil {
+ Yyerror("multiple nil cases in type switch (first at %v)", niltype.Line())
+ } else {
+ niltype = ncase
+ }
case n1.Op != OTYPE && n1.Type != nil: // should this be ||?
Yyerror("%v is not a type", Nconv(n1, FmtLong))
// reset to original type
--- /dev/null
+// errorcheck
+
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+func f(e interface{}) {
+ switch e.(type) {
+ case nil, nil: // ERROR "multiple nil cases in type switch"
+ }
+
+ switch e.(type) {
+ case nil:
+ case nil: // ERROR "multiple nil cases in type switch"
+ }
+}