You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
omitempty incorrectly looks at values behind pointers #371
isEmpty is called on a fully dereferenced struct, but if the original field type of the struct was a pointer to a struct, then omitempty should be taken to mean "drop if nil, otherwise output". In other words: isEmpty on any pointer type should return true precisely when the pointer is nil. This is currently not what happens because the field value is fully dereferenced.
This is a leftover from #360. The issue is demonstrated by the failure in #370.
I can confirm it broke in the v1.2.0 release; it works as expected in v1.1.0. It's probably d138d7a that introduced this; that changed it to always call eindirect.
Not sure yet when I'll look at this, but happy to review and accept patches in the meanwhile.
Activity
Add test for omitempty with pointers
arp242 commentedon Oct 24, 2022
I can confirm it broke in the v1.2.0 release; it works as expected in v1.1.0. It's probably d138d7a that introduced this; that changed it to always call
eindirect.Not sure yet when I'll look at this, but happy to review and accept patches in the meanwhile.
Evaluate omitempty against un-dereferenced fields
Evaluate omitempty against un-dereferenced fields
Evaluate omitempty against un-dereferenced fields (#392)