Skip to content

Commit

Permalink
Fix Make() not using bitstream for 0-field structs
Browse files Browse the repository at this point in the history
See #42
  • Loading branch information
flyingmutant committed Jan 8, 2023
1 parent acf5ed3 commit 12ff959
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions make.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,13 @@ func genAnyStruct(typ reflect.Type) *Generator[any] {

return Custom[any](func(t *T) any {
s := reflect.Indirect(reflect.New(typ))
for i := 0; i < numFields; i++ {
f := reflect.ValueOf(fieldGens[i].value(t))
s.Field(i).Set(f)
if numFields == 0 {
t.s.drawBits(0)
} else {
for i := 0; i < numFields; i++ {
f := reflect.ValueOf(fieldGens[i].value(t))
s.Field(i).Set(f)
}
}
return s.Interface()
})
Expand Down

0 comments on commit 12ff959

Please sign in to comment.