Skip to content

Commit

Permalink
obj: fix bug in marshal of nulls in []interface{}.
Browse files Browse the repository at this point in the history
Yes, []interface{} *specifically*.  For any other []*ConcreteT, this bug would not strike.

Never let anyone tell you that reflection is easy nor fun.  It's a maze of twisty little passages and you are extremely likely to be eaten by a grue.

Signed-off-by: Eric Myhre <hash@exultant.us>
  • Loading branch information
warpfork committed Nov 16, 2017
1 parent f97cb67 commit 599ce5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions obj/marshalWildcard.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type marshalMachineWildcard struct {
func (mach *marshalMachineWildcard) Reset(slab *marshalSlab, rv reflect.Value, rt reflect.Type) error {
// If the interface contains nil, go no further; we'll simply yield that single token.
if rv.IsNil() {
mach.delegate = nil
return nil
}
// Pick, reset, and retain a delegate machine for the interior type.
Expand Down
2 changes: 2 additions & 0 deletions obj/objFixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,8 @@ var objFixtures = []struct {
{title: "nulls in midst of arrays",
sequence: fixtures.SequenceMap["null in middle of array"],
marshalResults: []marshalResults{
{title: "from []iface",
valueFn: func() interface{} { return []interface{}{"one", nil, "three", nil, "five"} }},
{title: "from []*str",
valueFn: func() interface{} {
one, three, five := "one", "three", "five"
Expand Down

0 comments on commit 599ce5a

Please sign in to comment.