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

[Bug] Double negation of a field throws a compilation error #2555

Open
queretareu opened this issue Aug 30, 2023 · 0 comments · May be fixed by #28497
Open

[Bug] Double negation of a field throws a compilation error #2555

queretareu opened this issue Aug 30, 2023 · 0 comments · May be fixed by #28497
Labels
bug Something isn't working

Comments

@queretareu
Copy link

🐛 Bug Report

The compiler throws an error when trying to multiply a field by a double negation of a field: 1field * (-(-1field)).
However, the compiler does not throw an error when directly assigning a double negation of a field to a variable.

Steps to Reproduce

Run the code snippet below in Leo with the command:

leo execute main

Code snippet to reproduce

program main.aleo {
    transition main() {
        let a: field = (-(-1field));            // This line compiles successfully
        let b: field = 1field * (-(-1field));   // This line throws a compilation error
    }
}

Stack trace & error message

       Leo ✅ Compiled 'main.leo' into Aleo instructions
Error [ECLI0377008]: Failed to execute the `build` command.
SnarkVM Error: Failed to parse string. Remaining invalid string is: "mul 1field --1field into r0;
"

Expected Behavior

The code snippet should compile successfully.

Your Environment

Leo version: leo 1.9.3
Rust version: rustc 1.70.0 (90c541806 2023-05-31)
Computer OS: Ubuntu 22.04.2 LTS

@queretareu queretareu added the bug Something isn't working label Aug 30, 2023
mikebenfield added a commit that referenced this issue Jan 30, 2025
It should be a unary operation followed by a negative value.

Fixes #2555
@mikebenfield mikebenfield linked a pull request Jan 30, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant