Skip to content

Disallow ref field to ref struct#62186

Merged
cston merged 1 commit intodotnet:release/dev17.3from
cston:no-ref-ref-struct
Jun 29, 2022
Merged

Disallow ref field to ref struct#62186
cston merged 1 commit intodotnet:release/dev17.3from
cston:no-ref-ref-struct

Conversation

@cston
Copy link
Copy Markdown
Contributor

@cston cston commented Jun 28, 2022

Disallow ref fields of ref struct type, to simplify escape analysis.

Relates to test plan #59194

@cston cston requested a review from a team as a code owner June 28, 2022 16:42
@ghost ghost added the Area-Compilers label Jun 28, 2022
@cston cston requested review from a team, AlekseyTs, RikkiGibson and jaredpar and removed request for a team June 28, 2022 16:44
@jcouv jcouv added the Bug label Jun 28, 2022
@jcouv jcouv added this to the 17.4 milestone Jun 28, 2022
@RikkiGibson RikkiGibson self-assigned this Jun 28, 2022
@cston cston changed the base branch from main to release/dev17.3 June 28, 2022 22:12
@RikkiGibson RikkiGibson modified the milestones: 17.4, 17.3 Jun 28, 2022
.class public sealed R2 extends [mscorlib]System.ValueType
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.IsByRefLikeAttribute::.ctor() = (01 00 00 00)
.field public valuetype R1& F
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unrelated: do we give a use-site error when a non-ref struct contains a ref field?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

do we give a use-site error when a non-ref struct contains a ref field?

No, we're not reporting a use-site error for use of such a field currently. There is an item in the test plan, and I'll add this in a follow-up PR.

@AlekseyTs
Copy link
Copy Markdown
Contributor

AlekseyTs commented Jun 29, 2022

Do we have an issue tracking the work to re-enable this scenario?

Copy link
Copy Markdown
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 1)

@cston cston merged commit 65eb3f5 into dotnet:release/dev17.3 Jun 29, 2022
@cston cston deleted the no-ref-ref-struct branch June 29, 2022 16:51
@cston
Copy link
Copy Markdown
Contributor Author

cston commented Jun 29, 2022

Do we have an issue tracking the work to re-enable this scenario?

#62243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants