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 error when assigning to an argument #1471

Open
fpoli opened this issue Nov 2, 2023 · 0 comments
Open

Internal error when assigning to an argument #1471

fpoli opened this issue Nov 2, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@fpoli
Copy link
Member

fpoli commented Nov 2, 2023

The program

fn foo<'a>(mut x: &'a mut i32, y: &'a mut i32) {
    x = y;
}

fails with an internal fold-unfold error. The workaround is to declare a new local variable x.

fn foo<'a>(mut x: &'a mut i32, y: &'a mut i32) {
    let mut x = x;
    x = y;
}

The fold-unfold is not at fault; the error is that the Viper encoding ends with

    _old$pre$0 = _1.val_ref
    _old$pre$1 = _2.val_ref
    exhale i32(_old$pre$0) && i32(_old$pre$1)

when the encoding above is such that _1.val_ref == _2.val_ref. One way to fix the encoding is to use an old(..) expression around those _old$pre$..:

    _old$pre$0 = old(_1.val_ref)
    _old$pre$1 = old(_2.val_ref)
    exhale i32(_old$pre$0) && i32(_old$pre$1)
@fpoli fpoli added the bug Something isn't working label Nov 2, 2023
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

No branches or pull requests

1 participant