Skip to content

Incorrect assignment in case of pointer to alias of slice #243

Description

@jvergison

Consider following declared types, as found in the github.com/golang/geo/s2 package:

package s2

type CellID uint64
type CellUnion []CellID

This package is then used in another file as follows:

type Filter struct {
  Cells *s2.CellUnion `json:"cells"`
}

Running ffjson for this file produces the following code, and no error messages:
j.Cells = &[]s2.CellID{}

However, this produces the following error when building:

cannot use []s2.CellID literal (type *[]s2.CellID) as type *s2.CellUnion in assignment

The correct code in this case would be

cu := s2.CellUnion([]s2.CellID{})
j.Cells = &cu

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions