mirror of
https://github.com/golang/go
synced 2024-11-18 18:54:42 -07:00
go.tools/go/types: fix ... parameter passing
Also: exclude test case from std test to fix build. Fixes golang/go#6344. R=adonovan CC=golang-dev https://golang.org/cl/13630043
This commit is contained in:
parent
95e4181bb5
commit
932a87ce16
@ -143,7 +143,7 @@ func (check *checker) argument(sig *Signature, i int, x *operand, passSlice bool
|
||||
typ = sig.params.vars[n-1].typ
|
||||
if debug {
|
||||
if _, ok := typ.(*Slice); !ok {
|
||||
check.dump("%s: expected slice type, got %s", sig.params.vars[n-1].Pos(), typ)
|
||||
check.dump("%s: expected unnamed slice type, got %s", sig.params.vars[n-1].Pos(), typ)
|
||||
}
|
||||
}
|
||||
default:
|
||||
@ -157,7 +157,7 @@ func (check *checker) argument(sig *Signature, i int, x *operand, passSlice bool
|
||||
check.errorf(x.pos(), "can only use ... with matching parameter")
|
||||
return
|
||||
}
|
||||
if _, ok := x.typ.(*Slice); !ok {
|
||||
if _, ok := x.typ.Underlying().(*Slice); !ok {
|
||||
check.errorf(x.pos(), "cannot use %s as parameter of type %s", x, typ)
|
||||
return
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ func TestStdfixed(t *testing.T) {
|
||||
"bug373.go", // TODO(gri) implement use checks
|
||||
"bug376.go", // TODO(gri) built-ins must be called (no built-in function expressions)
|
||||
"issue3924.go", // TODO(gri) && and || produce bool result (not untyped bool)
|
||||
"issue4847.go", // TODO(gri) initialization cycle error not found
|
||||
)
|
||||
}
|
||||
|
||||
|
6
go/types/testdata/expr3.src
vendored
6
go/types/testdata/expr3.src
vendored
@ -380,3 +380,9 @@ func _calls() {
|
||||
fi(0, g2)
|
||||
fi(0, g2 /* ERROR "2-valued expression" */ ())
|
||||
}
|
||||
|
||||
func issue6344() {
|
||||
type T []interface{}
|
||||
var x T
|
||||
fi(x...) // ... applies also to named slices
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user