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 in loop fixed-point computation #351

Open
sonmarcho opened this issue Nov 10, 2024 · 0 comments
Open

Bug in loop fixed-point computation #351

sonmarcho opened this issue Nov 10, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@sonmarcho
Copy link
Member

sonmarcho commented Nov 10, 2024

This triggers a bug (comes from investigating #270 - it is a different bug):

pub enum List<T> {
    Cons(T, Box<List<T>>),
    Nil,
}

fn foo(h : &u8, mut t: &List<u8>) {
    let mut last = h;
    while let List::Cons(ht, tt) = t
    {
        last = ht;
        t = &*tt;
    }
}

The error is:

[Error] In file InterpreterLoopsFixedPoint.ml, line 680:
The sets of abstractions we need to end per region group are not pairwise disjoint

If we use the same lifetime for the two shared borrows, the translation succeeds:

pub enum List<T> {
    Cons(T, Box<List<T>>),
    Nil,
}

fn foo<'a>(h : &'a u8, mut t: &'a List<u8>) {
    let mut last = h;
    while let List::Cons(ht, tt) = t
    {
        last = ht;
        t = &*tt;
    }
}

The issue will be solved once we finish generalizing the support for loops (to add nested loops for instance).

@sonmarcho sonmarcho added the bug Something isn't working label Nov 10, 2024
@sonmarcho sonmarcho self-assigned this Nov 10, 2024
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