You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The frontend could parse omitted pointer typess at the end of the
type, but not in the middle, so code like []*[][]int{{{1}}} failed.
Test case is in https://golang.org/cl/123477.
Fixesgolang/go#26340
Reviewed-on: https://go-review.googlesource.com/123479
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262641 138bc75d-0d04-0410-961f-82ee72b054a4
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?
What did you expect to see?
No error.
What did you see instead?
Note that a standalone slice literal
S{ {1}, }
is accepted. Also if it ismap[string]S
instead ofmap[string]*S
, or[1]S
instead of[1]*S
, it is also accepted.cc @ianlancetaylor
The text was updated successfully, but these errors were encountered: