Closed
Description
What version of Go are you using (go version
)?
go version go1.10.3 gccgo (GCC) 9.0.0 20180709 (experimental) linux/amd64
What did you do?
package p
type S []T
type T struct { x int }
var _ = map[string]*S{
"a": {
{ 1 },
},
}
var _ = [1]*S{ { {1}, } }
What did you expect to see?
$ go tool compile x5.go
$
No error.
What did you see instead?
$ gccgo -c x5.go
x5.go:8:3: error: may only omit types within composite literals of slice, array, or map type
{ 1 },
^
x5.go:12:18: error: may only omit types within composite literals of slice, array, or map type
var _ = [1]*S{ { {1}, } }
^
Note that a standalone slice literal S{ {1}, }
is accepted. Also if it is map[string]S
instead of map[string]*S
, or [1]S
instead of [1]*S
, it is also accepted.