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

Using field access fails termination checking, while it succeeds with destructuring assignment #911

Open
utaal opened this issue Nov 24, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@utaal
Copy link
Contributor

utaal commented Nov 24, 2023

Given this definition:

struct Node<V> {
    v: V,
    next: Option<Box<Node<V>>>,
}

This works:

impl<V> Node<V> {
    #[ghost]
    fn len_logic(self: Node<V>) -> Int {
        {
            let Node { v: _, next } = self;
            1 + match next {
                Some(next) => next.len_logic(),
                None => 0,
            }
        }
    }
}

While this fails with "Cannot prove termination for len_logic":

impl<V> Node<V> {
    #[ghost]
    fn len_logic(self: Node<V>) -> Int {
        {
            1 + match self.next {
                Some(next) => next.len_logic(),
                None => 0,
            }
        }
    }
}

Note that the only difference is how next is accessed.

@xldenis xldenis self-assigned this Nov 26, 2023
@xldenis xldenis added the bug Something isn't working label Nov 26, 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

2 participants