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

Fix ref analysis of self-assignment #75618

Merged
merged 4 commits into from
Oct 30, 2024

Conversation

jjonescz
Copy link
Member

Fixes #75592.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Oct 24, 2024
@jjonescz jjonescz marked this pull request as ready for review October 24, 2024 11:45
@jjonescz jjonescz requested a review from a team as a code owner October 24, 2024 11:45
Copy link
Member

@jaredpar jaredpar left a comment

Choose a reason for hiding this comment

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

Think the error is in the wrong place here.

@dotnet dotnet deleted a comment from jjonescz Oct 24, 2024
@jjonescz
Copy link
Member Author

@jaredpar for another look, thanks

@@ -26477,6 +26477,12 @@ static ref S F2(S x2)

var comp = CreateCompilation(source, targetFramework: s_targetFrameworkSupportingByRefLikeGenerics);
comp.VerifyEmitDiagnostics(
// (12,26): error CS8350: This combination of arguments to 'Program<S>.F1(ref S)' is disallowed because it may expose variables referenced by parameter 'x1' outside of their declaration scope
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a variation of this test where the signature of F1 is

static ref S F1(ref S x1)

@jjonescz jjonescz enabled auto-merge (squash) October 30, 2024 10:18
@jjonescz jjonescz merged commit 5d355f6 into dotnet:main Oct 30, 2024
24 checks passed
@jjonescz jjonescz deleted the 75592-CyclicAssignment branch October 30, 2024 11:49
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Oct 30, 2024
@jjonescz jjonescz modified the milestones: Next, 17.13 P2 Nov 25, 2024
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 this pull request may close these issues.

Cyclic assignment should generate a ref safety error
3 participants