Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporting of while condition doesn't save line #902

Open
MrDaiki opened this issue Sep 16, 2024 · 1 comment
Open

Reporting of while condition doesn't save line #902

MrDaiki opened this issue Sep 16, 2024 · 1 comment

Comments

@MrDaiki
Copy link
Collaborator

MrDaiki commented Sep 16, 2024

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).

@vbgl
Copy link
Member

vbgl commented Sep 17, 2024

The issue with the line number in the error message is addressed by either #903 or #904.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants