cmd/compile: accepts invalid function type
dvyukov opened this issue · 5 comments
dvyukov commented
gc successfully compiles the following code:
package a
var f func((i), _ int)
both gccgo and gotype reject it saying:
error: invalid named/anonymous mix
expected identifier
Spec does not allow parenthesis there.
go version devel +be2a3e2 Thu Jul 2 08:29:33 2015 +0000 linux/amd64
dvyukov commented
@griesemer for spec treatment
griesemer commented
The spec does allow parentheses around types, but not around parameter names; e.g.: func((int), (float32)) ((int)) is valid.
The example above is incorrect because it mixes parameters with names (_) and w/o names (1st parameter).
odeke-em commented
odeke-em commented
To be clear, the problem still exists on go1.6.2 but on tip (go1.7) but seems fixed
https://play.golang.org/p/QI6Cmo92sN
griesemer commented
This may have been fixed a while back with https://go-review.googlesource.com/20748 . Closing.