jasmin
jasmin copied to clipboard
Bad errors with 128/256-bit rotations
trafficstars
Pre-typing rejects the following program:
export
fn rot(reg u128 x) -> reg u128 {
x <<r= 4;
return x;
}
line 3 (2-11): typing error: can not implicitly cast u64 into u128
Due to this line, pre-typing infers that the rotation operator is applied to a 64-bit value, thus produces a 64-bit value, which cannot be assigned to the 128-bit variable x.
If the rotation operator is manually annotated as <<r 128u, the error is slightly less cryptic:
typing error: invalid operator <<r128u
Note that the discrepancy with shifts (the type-checker is happy with 128-bit shifts, asm-gen complains) makes the error even more confusing.
Reported by @cos-imo.