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

Bind methods in pure #412

Merged
merged 4 commits into from
Jan 8, 2025
Merged

Conversation

Nadrieril
Copy link
Member

@Nadrieril Nadrieril commented Jan 7, 2025

The last few Charon PRs made it so we can support cases where the generics for a method fn item aren't a simple concatenation of the trait_decl/trait_impl generics + the method generics. I hadn't yet propagated these changes into Pure; this PR does that. This happens to simplify the extraction of impl methods quite a bit because we now have the correct explicit_info available.

For simplicity I did not attempt to make the de_bruijn_ids correct in Pure since we don't need them to be. I commented the relevant places appropriately so we know what's happening if we end up needing more complex binding situations in the future.

@Nadrieril Nadrieril requested a review from sonmarcho January 7, 2025 14:33
Copy link
Member

@sonmarcho sonmarcho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Checking that I understand: the generic_origin is useful only when extracting trait impls, because there we do need two levels of bindings, one for the generics bound at the level of the trait impl, and another at the level of the item itself, like so:

struct FooImpl T { (* Item level *)
    f = fun U -> f0 T U (* Method level *)
}

Correct?

@Nadrieril
Copy link
Member Author

the generic_origin is useful only when extracting trait impls

There are also two levels of bindings in trait decls:

Record OfType_t (Self : Type) := mkOfType_t { (* Item level *)
  OfType_t_of_type : forall {T : Type} (toTypeInst : ToType_t T Self), T ->  (* Method level *)
    result Self;
}.

but yes that's exactly the idea.

@Nadrieril Nadrieril merged commit dd87c9d into AeneasVerif:main Jan 8, 2025
6 checks passed
@Nadrieril Nadrieril deleted the bind-methods-in-pure branch January 8, 2025 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants