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

C# out param is not reported as an error in visual studio if a local function is called. #69775

Closed
vsfeedback opened this issue Aug 31, 2023 · 3 comments · Fixed by #70563
Closed
Assignees
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
I have attached a minimum reproducible project.
Notice the out method called 'bug' can compile even though the out parameter is not set.

The whole function:

    /// <summary>this compiles and it should not.</summary>
    static void bug(out int a)
    {
        bool hasLevel() => true;
        hasLevel();
    }

OutBug.zip


Original Comments

Feedback Bot on 8/20/2023, 06:54 PM:

(private comment, text removed)


Original Solutions

(no solutions)

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 31, 2023
@jcouv jcouv self-assigned this Sep 6, 2023
@jcouv jcouv added this to the 17.9 milestone Sep 6, 2023
@jcouv jcouv added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 6, 2023
@jcouv
Copy link
Member

jcouv commented Oct 16, 2023

This issue was also reported in #70391 (comment) and @SirCxyrtyx offered some details on investigation there.

@SirCxyrtyx
Copy link

Bug appears to have been introduced in 0ffa3fa.

That same commit also introduced the PrimaryConstructors_15 flow analysis test, which seems to be quite flawed?

public void PrimaryConstructors_15()

For this code:

class B(out int x)
{
    int X() => x = 1;
}

It asserts that x is definitely assigned on entry to X(), (which it isn't). I'm not sure why data flow analysis of this situation is being tested at all tbh, since a primary constructor out param cannot be accessed from a method.

@jcouv jcouv assigned AlekseyTs and unassigned jcouv Oct 24, 2023
@jcouv
Copy link
Member

jcouv commented Oct 24, 2023

Assigned to @AlekseyTs as it looks like this changed due to primary constructor work

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