Skip to content

Commit

Permalink
bindnode: When assigning a string into a kinded union, it must still …
Browse files Browse the repository at this point in the history
…look for a potentially complex type as the recipient.
  • Loading branch information
warpfork committed Aug 14, 2021
1 parent 28bc230 commit 6631886
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions node/bindnode/repr.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,24 @@ func (w *_assemblerRepr) AssignString(s string) error {
if member.Name() != name {
continue
}
valPtr := reflect.New(goTypeString)
valPtr.Elem().SetString(s)
unionSetMember(w.val, idx, valPtr)
return nil

// TODO: DRY with behavior below.
w2 := *w
goType := w.val.Field(idx).Type().Elem()
valPtr := reflect.New(goType)
w2.val = valPtr.Elem()
w2.schemaType = member
w2.finish = func() error {
if w.finish != nil {
if err := w.finish(); err != nil {
return err
}
}
unionSetMember(w.val, idx, valPtr)
return nil
}

return w2.AssignString(s)
}
panic("TODO: GetMember result is missing?")
case schema.UnionRepresentation_Stringprefix:
Expand Down

0 comments on commit 6631886

Please sign in to comment.