if ellipsisOk && p.tok == token.ELLIPSIS {
pos := p.pos
p.next()
- typ := p.tryType()
+ typ := p.tryType() // don't use parseType so we can provide better error message
+ if typ == nil {
+ p.Error(pos, "'...' parameter is missing type")
+ typ = &ast.BadExpr{pos}
+ }
if p.tok != token.RPAREN {
- p.Error(pos, "can use '...' for last parameter only")
+ p.Error(pos, "can use '...' with last parameter type only")
}
return &ast.Ellipsis{pos, typ}
}
`package main; func main() { _ = (<-chan int)(x) }` + "\n",
`package main; func main() { _ = (<-chan <-chan int)(x) }` + "\n",
`package main; func f(func() func() func())` + "\n",
- `package main; func f(...)` + "\n",
+ `package main; func f(...T)` + "\n",
`package main; func f(float, ...int)` + "\n",
`package main; type T []int; var a []bool; func f() { if a[T{42}[0]] {} }` + "\n",
`package main; type T []int; func g(int) bool { return true }; func f() { if g(T{42}[0]) {} }` + "\n",