Skip to content

Fix compile issue in generated bitset XXChoiceValues struct #1068

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zhangw
Copy link

@zhangw zhangw commented Apr 26, 2025

Before the fix, the generated bitset-related code looked like this:

type PresenceMapChoiceValue uint8
type PresenceMapChoiceValues struct {
FooField PresenceMapChoiceValue
BarField PresenceMapChoiceValue
}
var PresenceMapChoice = PresenceMapChoiceValues{uint64(0), uint64(1)}

This caused a compile error:
cannot use uint64(0) (constant 0 of type uint64) as PresenceMapChoiceValue value in struct literal
compilerIncompatibleAssign

The issue is that uint64(0) cannot be directly assigned to a field of type PresenceMapChoiceValue (uint8 alias).

After the fix, the generated code is:
var PresenceMapChoice = PresenceMapChoiceValues{0, 1}

This is simple, correct, and compiles without the issues before.

@vyazelenko
Copy link
Contributor

@zhangw Please add a test for this fix.

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