Skip to content
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

Refactor well-definedness of field acesses and permission division #451

Merged
merged 3 commits into from
Feb 23, 2023

Conversation

gauravpartha
Copy link
Contributor

@gauravpartha gauravpartha commented Feb 22, 2023

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.

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.
Copy link
Contributor

@marcoeilers marcoeilers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I just left two comments with cosmetic suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants