Update feature/ptoken with master#849
Merged
jberthold merged 5 commits intofeature/p-tokenfrom Nov 16, 2025
Merged
Conversation
Co-authored-by: Daniel Cumming <124537596+dkcumming@users.noreply.github.com>
Co-authored-by: devops <devops@runtimeverification.com>
Co-authored-by: devops <devops@runtimeverification.com> Co-authored-by: Julian Kuners <julian.kuners@gmail.com>
This PR implements semantics to cast (transmute) an integer into an enum if that enum is known to have no fields in it's variants. Some things to consider that influence this PR: 1. Transmute is only possible between the same width bits (e.g. `u8 -> i8` fine, `u8 -> u16` not fine); 2. Discriminants are stored as `u128` in the type data even if they are unsigned at the source level; 3. An integer transmuted into an enum is wellformed as long as the bit pattern matches a discriminant; The combination of these points mean that the approach to soundly casting an integer into an enum is to treat the incoming integer as unsigned (converting if signed), and check if that value is in the discriminants. If yes, follow to the corresponding variant position; if not return `#UBErrorInvalidDisciminantsInEnumCast`. The added code has meant a work around with retrieving the discriminant of a thunked cast can be removed. All added tests that should pass do except for one which is failing, I have made an issue for this as it is related to decoding negative discriminant enum types from an allocation.
Co-authored-by: devops <devops@runtimeverification.com> Co-authored-by: Daniel Cumming <124537596+dkcumming@users.noreply.github.com>
jberthold
approved these changes
Nov 16, 2025
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.
Uh oh!
There was an error while loading. Please reload this page.