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

Internal compiler error when reassigning a mutable lambda variable to one with a different environment type #2139

Closed
alexvitkov opened this issue Aug 3, 2023 · 1 comment · Fixed by #2172
Labels
bug Something isn't working

Comments

@alexvitkov
Copy link
Contributor

alexvitkov commented Aug 3, 2023

Aim

This code type-checks properly, but an assertion fails during SSA generation.
The reassignment is invalid since the two lambdas have different environment types, and should be caught during type-checking.

fn main() {
    let a: u32 = 1;
    let b: u32 = 1;

    let mut f = || a;
    f = || a + b;

    f();
}

Expected Behavior

We may want to support this behavior long term, but it's difficult since the lambdas are of different types, so for the time being I think we should throw a type error that the assignment is invalid.

Bug

The compiler crashes on the code above

To Reproduce

Compile the code above

Installation Method

Compiled from source

Nargo Version

nargo 0.9.0

Additional Context

No response

Would you like to submit a PR for this Issue?

Yes

Support Needs

No response

@alexvitkov alexvitkov added the bug Something isn't working label Aug 3, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Aug 3, 2023
@jfecher
Copy link
Contributor

jfecher commented Aug 3, 2023

We may want to support this behavior long term, but it's difficult since the lambdas are of different types, so for the time being I think we should throw a type error that the assignment is invalid.

I agree with this assessment, lets issue a type error now and we can look into allowing this later

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
Archived in project
3 participants