jasmin
jasmin copied to clipboard
Reporting of while condition doesn't save line
Issue
While working on an example program, I found a compilation error which I felt troubling. Here is a minimal example :
export fn test() -> reg u32 {
reg u32 i,j,result;
result = 0;
i=3;
j=4;
while (i <(j+1)){
result += 1;
}
return result;
}
This code is wrong because you cannot increment j in the while condition. The problem is in the error report :
line -1 (-1):
compilation error in function test:
asmgen: invalid rexpr for oprd (RDX +32u ((32u) 1))
invalid rexpr for word
The location of the bug is not displayed correctly, making debugging hard. For whatever reason, the same code with a if statement return the correct location, so the bug is really bounded to while conditions.
This kind of error could potentially be captured before typing (if we consider that arithmetical expressions are not allowed in conditional).
The issue with the line number in the error message is addressed by either #903 or #904.