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

Backport to v1: Prevent "Any" fields from pointing to *interface{} #1591

Merged
merged 2 commits into from Mar 14, 2018

Conversation

@xoob
Copy link

@xoob xoob commented Mar 14, 2018

This is a backport of the bugfix from master #1584 (86448e9) to the v1 stable branch, as requested by @raphael.


We fix an issue where non-required fields of kind "Any" were generated
as a pointer to *interface{}. This broke the Go compiler which failed
with the error "type *interface {} is pointer to interface, not
interface".

To prevent this, we teach AttributeDefinition.IsPrimitivePointer that
AnyKind should never be converted to a pointer, since it already is an
interface. The change also adds a test case.

This is a backport of #1584 to the "v1" stable branch.

xoob added 2 commits Mar 14, 2018
We fix an issue where non-required fields of kind "Any" were generated
as a pointer to *interface{}. This broke the Go compiler which failed
with the error "type *interface {} is pointer to interface, not
interface".

To prevent this, we teach AttributeDefinition.IsPrimitivePointer that
AnyKind should never be converted to a pointer, since it already is an
interface. The change also adds a test case.

This is a backport of goadesign#1584 to the "v1" stable branch.
@raphael
Copy link
Member

@raphael raphael commented Mar 14, 2018

Thank you!

@raphael raphael merged commit 10dcae6 into goadesign:v1 Mar 14, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xoob added a commit to xoob/goa that referenced this issue Mar 18, 2018
A previous patch in [goadesign#1591][1] addressed an issue where optional fields
of kind "Any" would result in a pointer to interface. We fix an
additional occurence of this problem in private user types, which follow
slightly different logic than the public media types previously fixed
and add a test case for private defs.

[1]: goadesign#1591
xoob added a commit to xoob/goa that referenced this issue Mar 18, 2018
A previous patch in [goadesign#1591][1] addressed an issue where optional fields
of kind "Any" would result in a pointer to interface. We fix an
additional occurence of this problem in private user types, which follow
slightly different logic than the public media types previously fixed
and add a test case for private defs.

[1]: goadesign#1591
raphael added a commit that referenced this issue Mar 19, 2018
* Add tests for private user type gen

* Prevent pointer to '*interface{}' in user types

A previous patch in [#1591][1] addressed an issue where optional fields
of kind "Any" would result in a pointer to interface. We fix an
additional occurence of this problem in private user types, which follow
slightly different logic than the public media types previously fixed
and add a test case for private defs.

[1]: #1591
raphael added a commit that referenced this issue Mar 19, 2018
* Add tests for private user type gen

* Prevent pointer to '*interface{}' in user types

A previous patch in [#1591][1] addressed an issue where optional fields
of kind "Any" would result in a pointer to interface. We fix an
additional occurence of this problem in private user types, which follow
slightly different logic than the public media types previously fixed
and add a test case for private defs.

[1]: #1591
@jiekang jiekang mentioned this pull request Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants