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

Ref fields spec on re-assignments can be simplified #64671

Closed
jcouv opened this issue Oct 12, 2022 · 0 comments · Fixed by dotnet/csharplang#6539
Closed

Ref fields spec on re-assignments can be simplified #64671

jcouv opened this issue Oct 12, 2022 · 0 comments · Fixed by dotnet/csharplang#6539
Labels
Area-Compilers New Language Feature - Ref Fields untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@jcouv
Copy link
Member

jcouv commented Oct 12, 2022

The current spec says:

For a ref reassignment in the form ...
1. x.e1 = ref e2: where x is safe-to-escape at least return only then e2 must have ref-safe-to-escape at least as large as x
2. e1 = ref e2: where e1 is a ref local or ref parameter then e2 must have a safe-to-escape equal to safe-to-escape for e1 and e2 must have ref-safe-to-escape at least as large as ref-safe-to-escape of the ref-safe-to-escape of e1

From offline discussion, we think this can be simplified to:

For a ref reassignment in the form `e1 = ref e2` both of the following must be true:
- e2 must have ref-safe-to-escape at least as large as the ref-safe-to-escape of e1
- e1 must have the same safe-to-escape as e2

The discussion of x.e1 case can be left as a side-note, but is covered by this more general rule.

Once the spec is updated, we can also update the corresponding comment in the compiler implementation.

Relates to test plan #59194 (ref fields)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers New Language Feature - Ref Fields untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant