jasmin-lang / jasmin

Language for high-assurance and high-speed cryptography
MIT License
271 stars 55 forks source link

Print scale in "invalid scale" error #949

Closed sarranz closed 1 month ago

sarranz commented 1 month ago

The following code

u256[1] a = { 0 };

export
fn main() -> reg u256 {
    reg ptr u256[1] p;
    p = a;

    reg u64 i;
    i = 0;

    reg u256 x;
    x = p[i];

    return x;
}

gives compilation error in function main: asmgen: invalid scale which is a bit confusing until you remember that i is being scaled by 32. If we access the array instead of a pointer, we get a beautiful compilation error in function main: asmgen: Invalid global address : (RIP +64u ((((64u) 32) *64u RAX) +64u ((64u) 0))) where we see the 32. Can we print the invalid scale in the error?

vbgl commented 1 month ago

Can we print the invalid scale in the error?

This seems doable.