Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccgo: type omission in slice literal (inside a map/array literal) should be accepted #26340

Closed
cherrymui opened this issue Jul 11, 2018 · 2 comments
Milestone

Comments

@cherrymui
Copy link
Member

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.

cc @ianlancetaylor

@gopherbot gopherbot added this to the Gccgo milestone Jul 11, 2018
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/123477 mentions this issue: test: add test of valid code that gccgo failed to compile

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/123479 mentions this issue: compiler: fix parsing of composite literals with omitted pointer types

gopherbot pushed a commit that referenced this issue Jul 12, 2018
Updates #26340

Change-Id: I3bc7cd544ea77df660bbda7de99a009b63d5be1b
Reviewed-on: https://go-review.googlesource.com/123477
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
hubot pushed a commit to gcc-mirror/gcc that referenced this issue Jul 13, 2018
    
    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.
    
    Fixes golang/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
@golang golang locked and limited conversation to collaborators Jul 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants