Skip to content

Conversation

@dkcumming
Copy link
Collaborator

This PR adds the field types of a union to the JSON. A more thorough investigation into unions should be done, but this is needed for iterator code with MaybeUninit present

Details

A union like:

union Union {
    signed: i8,
    unsigned: u8,
}

currently serialises to:

[
  27,
  {
    "UnionType": {
      "name": "Union",
      "adt_def": 7,
      "layout": {
        "fields": {
          "Union": 2
        },
        "variants": {
          "Single": {
            "index": 0
          }
        },
        "abi": {
          "Aggregate": {
            "sized": true
          }
        },
        "abi_align": 1,
        "size": {
          "num_bits": 8
        }
      }
    }
  }
]

and afterwards serialises to:

[
  27,
  {
    "UnionType": {
      "name": "Union",
      "adt_def": 7,
      "fields": [
        2,
        9
      ],
      "layout": {
        "fields": {
          "Union": 2
        },
        "variants": {
          "Single": {
            "index": 0
          }
        },
        "abi": {
          "Aggregate": {
            "sized": true
          }
        },
        "abi_align": 1,
        "size": {
          "num_bits": 8
        }
      }
    }
  }
]

where 2 is i8, and 9 is u8.

@automergerpr-permission-manager automergerpr-permission-manager bot merged commit 20a1bbd into master Nov 18, 2025
5 checks passed
@automergerpr-permission-manager automergerpr-permission-manager bot deleted the dc/union-fields branch November 18, 2025 15:28
automergerpr-permission-manager bot pushed a commit to runtimeverification/mir-semantics that referenced this pull request Nov 21, 2025
This PR brings into the K AST the fields and layout of unions that were
updated in #854 which is the stable-mir-json update
runtimeverification/stable-mir-json#105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants