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
Variable capture: synchronize with aliases in nested scopes #14035
base: main
Are you sure you want to change the base?
Conversation
| @@ -562,7 +583,7 @@ module Flow<InputSig Input> implements OutputSig<Input> { | |||
|
|
|||
| /** | |||
| * Holds if `access` is a reference to `ce` evaluated in the `i`th node of `bb`. | |||
| * The reference is restricted to be in the same callable as `ce` as a | |||
| * The reference is restricted to be nested within the same callable as `ce` as a | |||
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.
With this update, I'd like this predicate renamed from localClosureAccess to localOrNestedClosureAccess. Or something like this - the "local" prefix certainly is no longer true.
| result = bb.getEnclosingCallable() and | ||
| // The reference to `ce` is allowed to occur in a more deeply nested context | ||
| closureExprGetEnclosingCallable(ce) = callableGetEnclosingCallable*(result) | ||
| ) |
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.
Could we merge closureExprGetAReferencingCallable and closureExprGetCallable into one predicate, please? I.e. add the following here:
| ) | |
| ) | |
| or | |
| result = closureExprGetEnclosingCallable(ce) |
| @@ -391,16 +391,6 @@ module Flow<InputSig Input> implements OutputSig<Input> { | |||
| msg = "ClosureExpr has no body" and not ce.hasBody(_) | |||
| } | |||
|
|
|||
| query predicate closureAliasMustBeLocal(ClosureExpr ce, Expr access, string msg) { | |||
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.
Perhaps, instead of deleting this check, could we update it to check that all aliases are either local or in a nested scope? Since that's what we now rely on.
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
When a variable refers to a closure, we emulate what would happen if that closure had been inlined at that point.