-
Notifications
You must be signed in to change notification settings - Fork 97
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
exploration: finally
#4507
base: master
Are you sure you want to change the base?
exploration: finally
#4507
Conversation
let k' = fun v1 -> interpret_catches env cases exp.at v1 k in | ||
let env' = { env with throws = Some k' } in | ||
interpret_exp env' exp1 k | ||
| TryE (exp1, cases, Some exp2) -> | ||
let k' v1 = | ||
let cleanup v2 = interpret_exp env exp2 (fun _ -> k v2) in |
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.
instead of ignoring what comes out of exp2
's evaluation, explicitly check that it is unit: use V.as_unit
let cleanup v2 = interpret_exp env exp2 (fun _ -> k v2) in | ||
interpret_catches env cases exp.at v1 cleanup in | ||
let env' = { env with throws = Some k' } in | ||
let k'' v2 = interpret_exp env' exp2 (fun _ -> k v2) in |
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.
here too!
src/mo_interpreter/interpret.ml
Outdated
let k' v1 = | ||
let cleanup v2 = interpret_exp env exp2 (fun _ -> k v2) in | ||
interpret_catches env cases exp.at v1 cleanup in | ||
let env' = { env with throws = Some k' } in |
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.
I'm not sure this is enough. Unless we disallow return
s and break
s from exp1
and cases
, I think you will need to redefine the rets
and lab
s continuations too, to execute the finally before proceeding. This is getting complicated....
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.
I think your current code will allow a return
(or break
) from exp1
or cases
to skip the finally clause - only if the execution falls through exp1
or cases
is the finally clause executed. A throw from cases
will probably also bypass the finally.
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.
Probably worth having a careful read of this https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/statements#1311-the-try-statement
(I am not entrely sure abou this...)
Let's figure out how to interpret
finally
first...TODO:
Throw
and regular continuations inawait.ml
(instead of desugaring)context
key sortCleanup
, stack up continuations of finally blocks onlykr
inawait.ml
tokrc
(CPSAwait
), passCleanup
continuations asc
async.ml
lowerCPSAwait
to that toocheck_ir.ml
, etc.do
...finally
(when there is nocatch
clause necessary)finally
clausetry
OtherPrim "call_raw"
+ testscps_asyncE
similarly toCallPrim/3