0xPolygonMiden / compiler

Compiler from MidenIR to Miden Assembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assembler cannot resolve `::std::math::u64::checked_lte`

greenhat opened this issue · comments

While working on #230 the assembler returned the following error:

VM assembly error:
  x assembly failed
  help: see diagnostics for details

Error:   x undefined procedure
    ,-[abi_transform_tx_kernel_get_inputs_4:67:32]
 66 |         push.4294967295.1
 67 |         exec.::std::math::u64::checked_lte
    :                                ^^^^^|^^^^^
    :                                     `-- unable to resolve this reference to its definition
 68 |         assert
    `----
Error:   x name resolution cannot proceed
    ,-[./asm/math/u64.masm:33:6]
 32 | #! The input values are assumed to be represented using 32 bit limbs, but this is not checked.
 33 | #! Stack transition looks as follows:
    :      ^^^^^|^^^^^
    :           `-- this name cannot be resolved
 34 | #! [b_hi, b_lo, a_hi, a_lo, ...] -> [c_hi, c_lo, ...], where c = (a + b) % 2^64
    `----

@bitwalker The checked variants were removed in 0xPolygonMiden/miden-vm#1142
Do we want to keep using the checked variants as intrinsics or switch to unchecked variants?

@greenhat We should replace the use of checked_* with the unchecked variant, but prefix the call with a call to std::math::u64::u32assert4 to check the inputs as expected.

For arithmetic operations, we should do the same, but additionally use the overflowing variants for the actual op (rather than unchecked), and assert that no overflow occurs.