spec: disallow duplicate keys via variables in keyed constructors #37682
What version of Go are you using (
The text was updated successfully, but these errors were encountered:
Matches the behavior of
I hope we agree that the latter is fine and correctly does the overwrite.
I see the error generated by
But I see your side of the argument also. If the semantics of the constructor are defined to require uniqueness, then we should check that.
We could get rid of the duplicate key error, as that's backwards compatible. It's harder to change the language to allow the constructor to panic, as that's not backwards compatible. Such a change really needs to be worth the churn, and I'm not sure that's true here.
If we go this route (make duplicates panic), we should also change the semantics of other keyed constructors (slices and arrays). But those seem harder to do, e.g.