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

Use bytes interface value for zero native type struct fields instead of dynamic list #981

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

patrickpichler
Copy link
Contributor

If a struct has a byte array/slice field and it happens to be the zero value, a dynamic list object was returned. This caused issues with functions taking Bytes via arguments, as the type checker will accept such functions, but they might fail at runtime.

To work around this, the raw bytes array/slice is returned in case of an zero value.

…of dynamic list

If a struct has a byte array/slice field and it happens to be the zero
value, a dynamic list object was returned. This caused issues with
functions taking `Bytes` via arguments, as the type checker will accept
such functions, but they might fail at runtime.

To work around this, the raw bytes array/slice is returned in case of an
zero value.
ext/native.go Outdated Show resolved Hide resolved
@TristonianJones
Copy link
Collaborator

/gcbrun

@patrickpichler patrickpichler force-pushed the fix/zero-values-bytes branch from 9e63be1 to f7b02bd Compare July 23, 2024 08:28
@TristonianJones
Copy link
Collaborator

/gcbrun

Copy link
Collaborator

@TristonianJones TristonianJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor nit, but otherwise LGTM

For most types, it is good enough to use the raw interface values for
null types. Hence the logic of getFieldValue has been adjusted to remove
some special handling code.
@TristonianJones
Copy link
Collaborator

/gcbrun

@TristonianJones TristonianJones merged commit 1f51886 into google:master Jul 31, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants