Fix missing closing parenthesis for non-int transparent struct boolean conversion#725
Merged
tannergooding merged 1 commit intoJul 13, 2026
Conversation
…n conversion The bool-to-transparent-struct implicit operator wrapped the value in a cast for types other than int/uint but emitted only the cast's closing parenthesis, dropping the one that closes the constructor argument. This produced code like new MyBoolean((byte)(value ? 1u : 0u); which fails to compile. Adds the missing parenthesis and a regression test covering the generate-helper-types boolean transparent struct emission, which previously had no golden coverage. Fixes dotnet#577 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #577.
The
bool-> transparent-struct implicit conversion operator wraps the value in a cast ((type)(...)) for backing types other thanint/uint, but theelsebranch inGenerateTransparentStructsemitted only the cast''s closing parenthesis and dropped the one that closes the constructor argument. For abyte;Booleantransparent struct this produced:which fails to compile. Now emits the balanced form:
The
int/uintbranches were already correct (they don''t add the extra cast wrapper).Also adds a regression test exercising the
generate-helper-typesboolean transparent struct emission -- this path had no golden coverage previously, which is how the bug shipped. Full suite: 3709 passing (existing 3708 byte-identical), build 0/0.Note
This PR description was drafted by Copilot on my behalf.