Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jvergison opened this issue Sep 5, 2018 · 5 comments
Open

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

jvergison opened this issue Sep 5, 2018 · 5 comments

Comments

@jvergison
Copy link

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
erikdubbelboer added a commit to erikdubbelboer/ffjson that referenced this issue Sep 6, 2018
When a type is a slice of another type we should use the type name
itself and not a slice of the elements of the slice.

Fixes pquerna#243
@erikdubbelboer
Copy link
Contributor

See #244

@andersfylling
Copy link

Has anyone verified PR #244 to actually work?
It lacks unit tests, so I'm just curious.

@erikdubbelboer
Copy link
Contributor

@andersfylling I have :) but I missed the question for a test case. I'll add this this weekend.

erikdubbelboer added a commit to erikdubbelboer/ffjson that referenced this issue Mar 23, 2019
When a type is a slice of another type we should use the type name
itself and not a slice of the elements of the slice.

Fixes pquerna#243
@erikdubbelboer
Copy link
Contributor

@andersfylling I have updated the pull request with a test case.

@jflipts
Copy link

jflipts commented Mar 27, 2020

This issue is still present in the current master branch, when will the fix be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants