DHowett / go-plist

A pure Go Apple Property List transcoder
Other
416 stars 97 forks source link

unmarshal into map with int keys results in panic #44

Open rogpeppe opened 5 years ago

rogpeppe commented 5 years ago

Unmarshaling into a map with int keys will result in a panic. Although this key type is expressly forbidden, it would be more friendly to return an error in this case, or at least produce a panic message that's clearer than this:

panic: reflect.Value.Convert: value of type string cannot be converted to type int [recovered]
    panic: interface conversion: string is not error: missing method Error

Example code:

https://play.golang.org/p/Qd8TRd2C0LV
DHowett commented 5 years ago

Is this error message descriptive enough, or should it be more specific?

=== RUN   TestInvalidMapUnmarshal
--- PASS: TestInvalidMapUnmarshal (0.00s)
    unmarshal_test.go:59: Error:  plist: type mismatch: tried to decode plist type `dictionary'
      into value of type `map[int]string'