-
Notifications
You must be signed in to change notification settings - Fork 196
Closed
Description
Thank you for publishing this lovely library. :)
This bug smells similar to #376. It is so similar that I did double check I was on trunk before sending this bug report.
% dlv exec $(command -v msgp)
Type 'help' for list of commands.
(dlv) sources
[...]
/Users/saj/Documents/src/go/pkg/mod/github.com/tinylib/msgp@v1.2.5-0.20241117134132-901ed0042e54/gen/decode.go
/Users/saj/Documents/src/go/pkg/mod/github.com/tinylib/msgp@v1.2.5-0.20241117134132-901ed0042e54/gen/elem.go
/Users/saj/Documents/src/go/pkg/mod/github.com/tinylib/msgp@v1.2.5-0.20241117134132-901ed0042e54/gen/encode.go
[...]
The following input works as expected.
package main
//go:generate msgp
type Flibbity struct {
A Flibs `msg:"a,omitempty"`
B Flibs `msg:"b,omitempty"`
}
type Flibs []Flib
type Flib struct {
X int8 `msg:"x"`
Y int8 `msg:"y"`
}Flibbity.MarshalMsg includes the omitempty tests.
// check for omitted fields
zb0001Len := uint32(2)
var zb0001Mask uint8 /* 2 bits */
_ = zb0001Mask
if z.A == nil {
zb0001Len--
zb0001Mask |= 0x1
}
if z.B == nil {
zb0001Len--
zb0001Mask |= 0x2
}
// variable map header, size zb0001LenThe following input demonstrates the problem.
package main
//go:generate msgp
type Flobbity struct {
A Flobs `msg:"a,omitempty"`
B Flobs `msg:"b,omitempty"`
}
type Flobs []Flob
type Flob struct {
X Numberwang `msg:"x"`
Y int8 `msg:"y"`
}
type Numberwang int8Flobbity.MarshalMsg is missing the omitempty tests.
// check for omitted fields
zb0001Len := uint32(2)
var zb0001Mask uint8 /* 2 bits */
_ = zb0001Mask
// variable map header, size zb0001LenCuriously, if we remove either one of A or B from the type definition of Flobbity, the second example also begins to work as expected.
Here is a repository with the sources above.
https://github.com/saj/tinylib-msgp-381
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels