-
Notifications
You must be signed in to change notification settings - Fork 21
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
Opaque extensions #1134
base: main
Are you sure you want to change the base?
Opaque extensions #1134
Conversation
faa2462
to
e1ec170
Compare
Adding a note here that I noticed while reviewing the test result for |
Thanks, I'm reviewing now. |
c89897f
to
85a9c55
Compare
Done. I also pushed a small commit to allow making a single method opaque inside an impl (regular non-trait impl). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that looks good to me :)
I have some minor comments.
I still need to test the PR on snippets of code.
test-harness/src/snapshots/toolchain__attribute-opaque into-fstar.snap
Outdated
Show resolved
Hide resolved
Oh great, that's a nice addition! |
We also need the opaque attribute to work on traits I think. We forgot that case in the design document. #[hax_lib::opaque]
trait Foo<X, Y> {
...
} Should be translated to: assume type foo: Type -> Type -> Type (and for fsti |
#[hax_lib::opaque]
fn opaque_function(){}
fn regular_function(){} Open this code snippet in the playground Gets translated to: val opaque_function: Prims.unit -> Prims.unit
assume val opaque_function': Prims.unit -> Prims.unit
let opaque_function = opaque_function'
let regular_function (_: Prims.unit): Prims.unit = () I don't think we want the |
We want it in the fsti (if we have an fsti). I can generate it only in interface mode. |
Yes that can be nice when we have unallowed |
Indeed, let's file an issue with a good description then. I think we don't care for this PR. |
Yes, let's do that. I am not sure what you described worked by the way. With:
fstar complains with:
|
Ah, you are right, there's a catch, you need an attribute to mark the [@@ FStar.Tactics.Typeclasses.tcclass]
val t_T (v_Self v_U: Type0) : Type0
[@@ FStar.Tactics.Typeclasses.tcinstance]
val impl:t_T u8 u8 |
@W95Psp This is fixed now |
6876469
to
1727e58
Compare
73c5404
to
568d400
Compare
…erasure mechanism.
568d400
to
6c474ff
Compare
We chatted quickly about this with @maximebuyse, the opaque traits are not implemented yet, either we implement that here or we open a follow up issue. |
We just noticed a few problems here:
|
Fixes #1119
We implement this design. The attribute
opaque
is introduced and allows to drop the content (erase) of functions, types, trait impls, consts, etc. to make them abstract. In this case we produce a type signature and an abstract definition (usingassume
in fstar). The interface-only include flag (cargo hax into -i '+:.....
) allows to erase easily many items. It relies on default rules that say if a selected item should be erased or not (see design doc).