They are not inaccessible, they are just inaccessible via reflect (at
the moment).

https://play.golang.org/p/_EnLPRvrHAz

fmt uses reflect to get the keys and values. With the addition of a map
iterator type in reflect (https://tip.golang.org/pkg/reflect/#MapIter),
the behaviour you see now will change.

On Sun, 2018-10-21 at 16:33 -0600, Burak Serdar wrote:
> Someone asked a question a few days ago related to this, and it's
> been
> bugging me since then.
>
> Is this an undefined behavior according to the spec?
>
> https://play.golang.org/p/RqgD492EZ9U
>
> The code results in a map with two NaN keys, both of which have nil
> values. I think having two NaN keys is reasonable, but I would expect
> them to be non-nil when iterated,
>
> Since they are inaccessible, would those map values be garbage
> collected? Or is there a hidden pointer somewhere in there where no
> one can reach?
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to