Skip to content

cm: do not use bool discriminant in variant, result, and option types #349

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

Merged
merged 8 commits into from
May 18, 2025

Conversation

ydnar
Copy link
Collaborator

@ydnar ydnar commented May 17, 2025

This PR implements a breaking change: BoolResult is now a uint8 instead of bool, due to how LLVM represents a boolean value as a single bit, ignoring the high 7 bits. This breaks variants and other tagged unions if a bool is used as the memory shape.

Fixes #344.

ydnar added 4 commits May 16, 2025 22:20
Tinygo (LLVM) handles bool values in a tagged union differently than Go.

Fixes #344.
Fixes issue where LLVM clobbers high 7 bits in a bool value when used as a shape for a variant, result, or option.

Fixes #344.
@ydnar ydnar self-assigned this May 17, 2025
@ydnar ydnar added the bug Something isn't working label May 17, 2025
@ydnar ydnar merged commit dd029f4 into main May 18, 2025
13 checks passed
@ydnar ydnar deleted the ydnar/issue344 branch May 18, 2025 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Corrupted value of type result<u64, tuple<option<u64>>>
1 participant