I think I've found a bug regarding reflect.ArrayOf. The go doc is a bit
light, but suggests that the resulting type is a proper array type.
However, I've found that the resulting type has a few flaws:


   1. The resulting array type violates part of the language spec about
   arrays: it cannot be used as a map key. Using an array whose type was
   created via reflect.ArrayOf as a key in a map results in a runtime panic:


*runtime error: hash of unhashable type [8]int32 *
   See the link below for an example program that shows this error.

   2. The resulting array type seems to violate the reflect package Go doc
   regarding reflect.Type and type equality. The package doc states this:


*    Type values are comparable, such as with the == operator. Two Type
   values are equal if they represent identical types. *
   And the section about type identity in the language spec states this:

   *    Two array types are identical if they have identical element types
   and the same array length.*

   However, an array type created using reflect.ArrayOf returns false when
   compared to an identical type that was *not* created using
   reflect.ArrayOf.

   The link below also shows an example of this erroneous behavior.

Demonstrations of these issues:
https://play.golang.org/p/Qu0irn2rCF

I am guessing I should just file a bug in a Github issue, but wanted to
first check to see if this, somehow, might be expected behavior. (And if
so, to learn why.)

----
*Josh Humphries*
jh...@bluegosling.com

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to