-
Notifications
You must be signed in to change notification settings - Fork 40
Fix tail resumptive analysis for vars #1154
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
Conversation
| case Stmt.Match(scrutinee, clauses, default) => !freeInExpr(scrutinee) && clauses.forall { | ||
| case (_, BlockLit(tparams, cparams, vparams, bparams, body)) => tailResumptive(k, body) | ||
| } && default.forall { stmt => tailResumptive(k, stmt) } | ||
| case Stmt.Region(BlockLit(tparams, cparams, vparams, bparams, body)) => tailResumptive(k, body) |
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.
Shouldn't this also be false then?
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.
If/when we change this, could we add an example where this fires / doesn't fire?
|
Nice that you apparently didn't have to change the VMTests! |
b-studios
left a comment
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 pre-approve :) Once you fixed / commented out the Scheme tests this is ready to go.
| case Stmt.Var(ref, init, capture, body) => tailResumptive(k, body) && !freeInExpr(init) | ||
| // Conceptually, a mutable variable definition can be seen as a handler for get and put operations. | ||
| // Treating this as tail-resumptive leads to a failure of semantics preservation | ||
| case Stmt.Var(ref, init, capture, body) => false |
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.
Not too relevant for the current PR, but would a use-mention distinction help here?
If we have variables/prompts that are merely mentioned, can we still consider the function to be tail-res?
As a very trivial example, is it safe to do something similar to the example, but not use x at all after declaring it? 🤔
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.
Is there an example that isn't just dead code (and would be handled by dead code elimination)?
batenwi
left a comment
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.
LGTM
Fixes #1153.