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 escape analysis errors are not reported for compound assignment #63852

Closed
cston opened this issue Sep 7, 2022 · 0 comments · Fixed by #74341
Closed

Ref escape analysis errors are not reported for compound assignment #63852

cston opened this issue Sep 7, 2022 · 0 comments · Fixed by #74341

Comments

@cston
Copy link
Member

cston commented Sep 7, 2022

No error is reported for x += y below. Verified the repro with csc.exe 3.11 and latest 4.4 preview.

using System;

ref struct S
{
    public static implicit operator S(Span<int> s) => default;
    public static S operator +(S a, S b) => b;
}

class Program
{
    static void F(ref S x)
    {
        Span<int> s = stackalloc int[10];
        S y = s;
        x += y;    // no error
        x = x + y; // error CS8352: 'y' ... may expose referenced variables outside of their declaration scope
    }
}
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 7, 2022
@jaredpar jaredpar added Bug Feature - Ref Fields and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 10, 2022
@jaredpar jaredpar added this to the 17.5 milestone Oct 10, 2022
@jaredpar jaredpar modified the milestones: 17.5, 17.6 Jan 5, 2023
@jaredpar jaredpar self-assigned this Jul 10, 2024
@jaredpar jaredpar modified the milestones: 17.6, 17.12 Jul 10, 2024
jaredpar added a commit to jaredpar/roslyn that referenced this issue Jul 10, 2024
These tests verify that issue dotnet#63852 is fixed. It was very likely fixed
as part of dotnet#73081

closes dotnet#63852
jaredpar added a commit to jaredpar/roslyn that referenced this issue Jul 15, 2024
These tests verify that issue dotnet#63852 is fixed. It was very likely fixed
as part of dotnet#73081

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

Successfully merging a pull request may close this issue.

2 participants