Skip to content

Conversation

@AlekseyTs
Copy link
Contributor

Closes #76847

@AlekseyTs AlekseyTs requested a review from a team as a code owner October 24, 2025 16:56
@AlekseyTs AlekseyTs requested a review from a team October 24, 2025 22:59
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For a second review

1 similar comment
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For a second review

@jcouv jcouv self-assigned this Oct 27, 2025
comp.VerifyDiagnostics(
// (5,20): warning CS0649: Field 'var.o' is never assigned to, and will always have its default value null
// internal other o;
Diagnostic(ErrorCode.WRN_UnassignedInternalField, "o").WithArguments("var.o", "null").WithLocation(5, 20),
Copy link
Member

@jcouv jcouv Oct 27, 2025

Choose a reason for hiding this comment

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

It's not obvious how this change in diagnostic output results from the change. Is this change expected? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not obvious how this change in diagnostic output results from the change. Is this change expected?

It is cased by changes in Binder_Statements.cs, we no longer treat body of ref var () => throw null as returning a reference to an instance of "@var" type. Therefore, we don't treat it as a possible write to the field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The behavior is consistent with explicit return statements

var delegateType = expr.GetFunctionType()?.GetInternalDelegateType();
delegateType?.AddUseSiteInfo(ref useSiteInfo);

if (expr is BoundMethodGroup { Methods: not [{ MethodKind: MethodKind.LocalFunction }] } &&
Copy link
Member

@jcouv jcouv Oct 27, 2025

Choose a reason for hiding this comment

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

Is this check for MethodKind just to avoid cascading diagnostics (ie. checking the InAttribute both on the local function declaration and again on the usage)?
nit: If so, consider leaving a comment #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (commit 2)

@AlekseyTs AlekseyTs enabled auto-merge (squash) October 27, 2025 21:23
@AlekseyTs AlekseyTs merged commit 64219bb into dotnet:main Oct 27, 2025
23 of 24 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Oct 27, 2025
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.

Unexpected metadata for function signature when defined as member vs local

3 participants