Refactor well-definedness of field acesses and permission division#451
Merged
Conversation
Now, the well-definedness of a field access first checks the well-definedness of a receiver and only afterwards checks whether there is enough permission (before the order was reversed). Now, the well-definedness of a permission division first checks the well-definedness of the dividend and the divisor and only afterwards checks the whether the divisor is nonzero (before the order was reversed). Moreover, in order to avoid checking whether permission to field accesses at the top-level of an accessibility predicate or permission introspection, the current implementation uses global state in a somewhat fragile way. Now, a different approach is used that avoids global state.
marcoeilers
approved these changes
Feb 23, 2023
marcoeilers
left a comment
Contributor
There was a problem hiding this comment.
LGTM, I just left two comments with cosmetic suggestions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now, the well-definedness of a field access first checks the well-definedness of a receiver and only afterwards checks whether there is enough permission (previously the order was reversed). Now, the well-definedness of a permission division first checks the well-definedness of the dividend and the divisor and only afterwards checks the whether the divisor is nonzero (before the order was reversed).
In the case of acc(e.f) and perm(e.f) (“PermAccess case”), the well-definedness check for e.f need not be checked. In all other cases (“NonPermAccess case”) such as “x := e.f”, the well-definedness check requires a permission check. In both cases, e.f is represented by the same AST subnode. Previously, Carbon differentiated the two cases in the well-definedness check with global state in a fragile way that relied on the fact that for the “NonPermAccess case” permission to e.f was checked before well-definedness of e was checke. Now, Carbon does not use global state for this differentiation (which then allowed me to also change the order of the checks). Instead, the expression module (responsible for orchestrating the definedness checks) makes sure that the components contributing to the definedness check never obtain field accesses as an input for which no definedness check is required.