Skip to content

Commit

Permalink
Fix Nat -> Word conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Oct 31, 2024
1 parent c57e7a9 commit 848c406
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion unison-runtime/src/Unison/Runtime/Builtin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ andb = binop0 0 $ \[p, q] ->
coerceType :: PackedTag -> SuperNormal Symbol
coerceType (PackedTag destType) =
unop0 1 $ \[v, tag] ->
TLetD tag UN (TLit $ N destType)
TLetD tag UN (TLit $ I $ fromIntegral destType)
$ TPrm CAST [v, tag]

-- unbox x0 ri x $
Expand Down
1 change: 1 addition & 0 deletions unison-runtime/src/Unison/Runtime/Machine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,7 @@ uprim2 !stk CAST !vi !ti = do
newTypeTag <- peekOffN stk ti
v <- upeekOff stk vi
stk <- bump stk
Debug.debugM Debug.Temp "CASTING" (v, newTypeTag)
poke stk $ UnboxedVal v (PackedTag newTypeTag)
pure stk
{-# INLINE uprim2 #-}
Expand Down
2 changes: 1 addition & 1 deletion unison-runtime/src/Unison/Runtime/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ matchNatVal = \case
pattern NatVal :: Word64 -> Val
pattern NatVal n <- (matchNatVal -> Just n)
where
NatVal n = UnboxedVal (fromEnum n) TT.natTag
NatVal n = UnboxedVal (fromIntegral n) TT.natTag

matchDoubleVal :: Val -> Maybe Double
matchDoubleVal = \case
Expand Down

0 comments on commit 848c406

Please sign in to comment.