Fix Unmarshaler call when value is missing (#439)

Fixes #431
This commit is contained in:
Thomas Pelletier
2020-09-12 14:42:04 -04:00
committed by GitHub
parent 5c94d86029
commit 65ca806488
2 changed files with 39 additions and 0 deletions
+4
View File
@@ -742,6 +742,10 @@ func (d *Decoder) valueFromTree(mtype reflect.Type, tval *Tree, mval1 *reflect.V
if mvalPtr := reflect.New(mtype); isCustomUnmarshaler(mvalPtr.Type()) {
d.visitor.visitAll()
if tval == nil {
return mvalPtr.Elem(), nil
}
if err := callCustomUnmarshaler(mvalPtr, tval.ToMap()); err != nil {
return reflect.ValueOf(nil), fmt.Errorf("unmarshal toml: %v", err)
}