jasmin
jasmin copied to clipboard
Cast of prim to small types gives no feedback
Consider this example
export fn f (reg u128 x y) -> reg u128 {
reg u128 z;
z = (32u)#VPAND(x, y);
return z;
}
This example compiles fine. The cast (32u) is silently ignored. I think this is done on purpose, but really confusing for the user that has no feedback on what happens. An error would be more user-friendly. Or a warning explaining that this is ignored.
The cast is "ignored" since VPAND is by default VPAND_128 and 32 < 128. Actually, the cast is there, but not taken into account for typing.
Actually after discussing a bit with @bgregoir, these are not really casts but instead instruction modifiers. Maybe we should think of another syntax then?
Here is another counter-intuitive example. The first one compiles fine, since (32u) is ignored like in the first example above. And the second fails with the message: "typing error: can not implicitly cast u32 into u64". While without (32u) they are both compiled to the same assembly.
export fn f (reg u64 x y) -> reg u64 {
reg u64 z;
reg u64 x1 y1;
x1 = x;
y1 = y;
z = (32u)#AND(x1, y1);
return z;
}
export fn f (reg u64 x y) -> reg u64 {
reg u64 z;
reg u64 x1 y1;
x1 = x;
y1 = y;
z = (32u)x1 & y1;
return z;
}