Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions kmir/src/kmir/kdist/mir-semantics/rt/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,14 @@ These helpers mark down, as we traverse the projection, what `Place` we are curr
rule #buildUpdate(Aggregate(variantIdx(0), ListItem(VALUE) .List), CtxWrapStruct CTXS)
=> #buildUpdate(VALUE, CTXS)

// Reinterpret union payloads through the accessed field type.
// This keeps the underlying bits and switches signedness/width for integer fields.
syntax Value ::= #unionFieldRead ( Value , Ty ) [function, total]
rule #unionFieldRead(Integer(VAL, WIDTH, _SIGNEDNESS), TY)
=> #intAsType(VAL, WIDTH, #numTypeOf(lookupTy(TY)))
requires #isIntType(lookupTy(TY))
rule #unionFieldRead(VAL, _TY) => VAL [owise]


syntax StackFrame ::= #updateStackLocal ( StackFrame, Int, Value ) [function]

Expand Down Expand Up @@ -512,24 +520,24 @@ The following rule resolves this situation by using the head element.

#### Unions
```k
// Case: Union is in same state as field projection
// Union field reads reuse the stored payload and reinterpret integer fields through the accessed type.
rule <k> #traverseProjection(
DEST,
Union(FIELD_IDX, ARG),
Union(_ACTIVE_FIELD_IDX, ARG),
projectionElemField(FIELD_IDX, TY) PROJS,
CTXTS
)
=> #traverseProjection(
DEST,
ARG,
#unionFieldRead(ARG, TY),
PROJS,
CtxFieldUnion(FIELD_IDX, ARG, TY) CTXTS
)
...
</k>
[preserves-definedness]

// TODO: Case: Union is in different state as field projection
// Union field reads are permitted regardless of the active field.
```

#### Ranges
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion kmir/src/tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
'transmute-u8-to-enum-fail',
'assert-inhabited-fail',
'iterator-simple',
'unions-fail',
'transmute-maybe-uninit-fail',
'ptr-through-wrapper-fail',
'test_offset_from-fail',
Expand Down
Loading