Skip to content

omitempty incorrectly looks at values behind pointers #371

Closed

Description

@joukewitteveen

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.

Activity

  1. added a commit that references this issue on Oct 24, 2022
  2. arp242 commented on Oct 24, 2022

    @arp242
    Collaborator

    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.

  3. added 2 commits that reference this issue on May 23, 2023
    a4df7e3
    2e4a1e8
  4. added a commit that references this issue on May 30, 2023
    d9b9172
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址