Allowing pointer of type to implement an interface causes errors for non-addressable types

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 1.3.3
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In GODRIVER-1356, we allowed a pointer to a type to implement the hooks we check for during BSON encoding/decoding (e.g. bsoncodec.Marshaler). This causes problems if the value being marshalled isn't addressable but a pointer to the value implements the hook. The registry will return the codec for the hook, but the codec will error because val.CanAddr returns false. See https://play.golang.org/p/GwmqXl5sFAx for a repro.

      As a side-note, I don't really understand why the value isn't addressable. Unfortunately, the registry does lookups using reflect.Type so it doesn't have enough information to know if the value is addressable or not.

            Assignee:
            Isabella Siu (Inactive)
            Reporter:
            Divjot Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: