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: erroneously accepts duplicate constant keys in map literal #28104

Closed
mdempsky opened this issue Oct 9, 2018 · 5 comments
Closed

gccgo: erroneously accepts duplicate constant keys in map literal #28104

mdempsky opened this issue Oct 9, 2018 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mdempsky
Copy link
Member

mdempsky commented Oct 9, 2018

Under Composite literals, the Go spec says "It is an error to specify multiple elements with the same field name or constant key value."

However, gccgo erroneously accepts this code:

package p

var _ = map[int]int{0: 0, 0: 0}

cmd/compile and go/types correctly emit an error.

/cc @ianlancetaylor

@gopherbot
Copy link

Change https://golang.org/cl/161357 mentions this issue: compiler: check duplicate keys in map literal

@gopherbot
Copy link

Change https://golang.org/cl/161357 mentions this issue: compiler: check duplicate keys in map composite literal

gopherbot pushed a commit to golang/gofrontend that referenced this issue Feb 14, 2019
Updates golang/go#28104

Change-Id: I9f313245b10d4a25549c1099b76eba96e775a0f6
Reviewed-on: https://go-review.googlesource.com/c/161357
Reviewed-by: Ian Lance Taylor <iant@golang.org>
kraj pushed a commit to kraj/gcc that referenced this issue Feb 15, 2019
    
    Updates golang/go#28104
    
    Reviewed-on: https://go-review.googlesource.com/c/161357


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268891 138bc75d-0d04-0410-961f-82ee72b054a4
@gopherbot
Copy link

Change https://golang.org/cl/162882 mentions this issue: compiler: check duplicate numeric keys in map literals

gopherbot pushed a commit to golang/gofrontend that referenced this issue Feb 27, 2019
Updates golang/go#28104

Change-Id: Ic31cdf29721d37529ade9c3cd00efa279cb2066f
Reviewed-on: https://go-review.googlesource.com/c/162882
Reviewed-by: Ian Lance Taylor <iant@golang.org>
kraj pushed a commit to kraj/gcc that referenced this issue Feb 27, 2019
    
    Updates golang/go#28104
    
    Reviewed-on: https://go-review.googlesource.com/c/162882


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269242 138bc75d-0d04-0410-961f-82ee72b054a4
@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 12, 2019
@dotaheor
Copy link

dotaheor commented Apr 9, 2022

It looks this has been fixed for non-bool keys in the latest gccgo versions.

Duplicate bool keys are still allowed: #35945

@gopherbot
Copy link

Change https://go.dev/cl/403954 mentions this issue: compiler: error for duplicate bool map keys

realqhc pushed a commit to realqhc/gofrontend that referenced this issue Aug 4, 2022
For golang/go#35945
Fixes golang/go#28104

Change-Id: I6d0f3188e99d99e92dabab68949d0d0d24841388
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/403954
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
@golang golang locked and limited conversation to collaborators May 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants