mirror of
https://github.com/golang/go
synced 2024-11-22 01:04:40 -07:00
type switch bug involving function parameter names
R=ken OCL=34232 CL=34232
This commit is contained in:
parent
ad9fabd769
commit
bebe06a784
@ -1920,8 +1920,12 @@ typehash(Type *at, int addsym, int d)
|
||||
break;
|
||||
|
||||
case TSTRUCT:
|
||||
for(t=at->type; t!=T; t=t->down)
|
||||
for(t=at->type; t!=T; t=t->down) {
|
||||
if(at->funarg) // walk into TFIELD in function argument struct
|
||||
h += PRIME7 * typehash(t->type, addsym, d+1);
|
||||
else
|
||||
h += PRIME7 * typehash(t, addsym, d+1);
|
||||
}
|
||||
break;
|
||||
|
||||
case TFUNC:
|
||||
|
@ -387,7 +387,7 @@ mkcaselist(Node *sw, int arg)
|
||||
continue;
|
||||
setlineno(c1->link->node);
|
||||
yyerror("duplicate case in switch");
|
||||
print(" previous case at %L\n",
|
||||
print("\tprevious case at %L\n",
|
||||
c1->node->lineno);
|
||||
}
|
||||
break;
|
||||
@ -400,7 +400,7 @@ mkcaselist(Node *sw, int arg)
|
||||
continue;
|
||||
setlineno(c1->link->node);
|
||||
yyerror("duplicate case in switch");
|
||||
print(" previous case at %L\n",
|
||||
print("\tprevious case at %L\n",
|
||||
c1->node->lineno);
|
||||
}
|
||||
break;
|
||||
|
19
test/fixedbugs/bug200.go
Normal file
19
test/fixedbugs/bug200.go
Normal file
@ -0,0 +1,19 @@
|
||||
// errchk $G $D/$F.go
|
||||
|
||||
// Copyright 2009 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 main
|
||||
|
||||
func main() {
|
||||
// 6g used to compile these as two different
|
||||
// hash codes so it missed the duplication
|
||||
// and worse, compiled the wrong code
|
||||
// for one of them.
|
||||
var x interface{};
|
||||
switch v := x.(type) {
|
||||
case func(int):
|
||||
case func(f int): // ERROR "duplicate"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user