-
Notifications
You must be signed in to change notification settings - Fork 234
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
Fixing mistaken erasure of effectful type applications #3518
Conversation
I have a check-world green with this: https://github.com/FStarLang/FStar/actions/runs/11153756864 |
val push_unit (ts : mltyscheme) : mltyscheme | ||
val pop_unit (ts : mltyscheme) : mltyscheme | ||
val push_unit (eff:e_tag) (ts : mltyscheme) : mltyscheme | ||
val pop_unit (ts : mltyscheme) : e_tag & mltyscheme |
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.
push_unit
is called when replacing the type arguments of a function with a unit.
pop_unit
is the converse, eliminating a polymorphic function with a type application where the type argument is extracted as unit.
We now record the effect of type application as an e_tag, i.e., Pure, Erasable, Impure
| None -> bs, U.comp_result c | ||
| Some (bs, b, rest) -> bs, U.arrow (b::rest) c in | ||
|
||
| None -> bs, etag_of_comp c, U.comp_result c |
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.
record the effect of the type instantiation
fun ctr -> | ||
let n = FStar_HyperStack_ST.op_Bang ctr in | ||
FStar_HyperStack_ST.testify () |
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.
interestingly, this was being dropped previously (testify: ((heap -> Type) -> ST unit)
)
let recall : 'p . unit -> unit = fun uu___ -> FStar_ST.gst_recall () | ||
let witness : 'p . unit -> unit = fun uu___ -> FStar_ST.gst_witness () |
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.
Both of these are really noops, but they are effectful type applications in F* and should not have been dropped
Fixes issue #3473
An effectful polymorphic function
f
at typea:Type -> Dv t
was typed in the ML extraction asunit -> t
.This fix types it now as
unit -Impure-> t
, ensuring that an applicationf a
is extracted asf ()
with effect Impure and so is ineligible for erasure, even ift
is an erasable type.