hax icon indicating copy to clipboard operation
hax copied to clipboard

[F* backend] Associated types are not extracted correctly in general

Open W95Psp opened this issue 1 year ago • 4 comments

The F* backend (and probably others) is not handling "non-trivial" associated type, e.g.:

pub trait Foo {
    type FooType;
}
pub trait Bar {
    type BarType: Foo;
    fn f() -> <Self::BarType as Foo>::FooType;
}

The F* backend doesn't leverage all the information contained in the impl_exprs.

This is related to #536

W95Psp avatar Mar 05 '24 11:03 W95Psp

There is a similar issue with projections. Here's an important example:

fn foo<F>(f: F) -> i32
where
    F: Fn(u64) -> i32,
{
    f(42)
}

The Fn trait is implemented as an extension of FnMut, which is itself an extension of FnOnce, and only FnOnce stores the output type as an associated type.

In the example above, figuring out the return type of f would require looking at the projection clause from the list of bounds on generic parameters.

This information is exported by the frontend here but ignored by the importer in the backend.

I don't think any backend correctly translates the example above at the moment.

paulmure avatar Jul 09 '24 22:07 paulmure

Hi @paulmure, thanks for your comment! That's true, the engine doesn't support at all equality constraints. That would be great to add support for that! Let me open a new issue. This one was more about the F* extraction which is broken for even less complicated things :sweat_smile:

W95Psp avatar Jul 18 '24 07:07 W95Psp

I had an issue that seems to be related. The equality constraints inside a trait type argument are not translated to f*: https://hax-playground.cryspen.com/#fstar/3b38e61b99/gist=cc40e5e2c6579d215293f9378b9e871f

maximebuyse avatar Sep 02 '24 14:09 maximebuyse

This issue has been marked as stale due to a lack of activity for 60 days. If you believe this issue is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar Dec 15 '24 02:12 github-actions[bot]