golang/go

cmd/compile: accepts invalid function type

dvyukov opened this issue · 5 comments

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

@griesemer for spec treatment

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).

I can't seem to reproduce this issue on my setup
screen shot 2016-07-24 at 1 20 29 am

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

This may have been fixed a while back with https://go-review.googlesource.com/20748 . Closing.