Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

No description provided.

@CyrusNajmabadi
Copy link
Member Author

@333fred i was debugging through #81113

The problem on the IDE side is that we try to call GetSymbolInfo on C.M and we get back a symbolinfo that says 'OverloadResolutionFailed' and only inccludes C.M() in the .CandidateSymbols not the .Symbol. This causes us to bail out as we don't want to simplify something in error.

Can you ptal here? It seems odd that the code is entirely correct and compiles without error, but we get back a wonky SymbolInfo like this.

I've included a debuggable test here for you in FunctionPointerTests. Thanks!

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

What is the actual issue here?

);
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75933")]
Copy link
Member

Choose a reason for hiding this comment

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

How is this related to this issue?

var memberAccess = root.DescendantNodes().OfType<MemberAccessExpressionSyntax>().Single();
var symbolInfo = semanticModel.GetSymbolInfo(memberAccess);

Assert.NotNull(symbolInfo.Symbol);
Copy link
Member

@333fred 333fred Nov 10, 2025

Choose a reason for hiding this comment

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

Please assert ToTestDisplayString, not just not null. #Resolved

}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/81113")]
public void TestGetSymbolInfo_Parethesized()
Copy link
Member

Choose a reason for hiding this comment

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

There's a typo in test name. Also the test doesn't seem useful as parens generally do nothing. I'd remove this test

Copy link
Member

Choose a reason for hiding this comment

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

The test is intentional to make sure we are walking through parentheses.

Copy link
Member

Choose a reason for hiding this comment

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

Also, I don't know what typo you are referring to?

Copy link
Member

Choose a reason for hiding this comment

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

Parethesized => Parenthesized

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the point is exactly that things work properly even in the presence of parens. We don't want a set of parens making it so that semantic info breaks again.

}
break;

case SyntaxKind.AddressOfExpression:
Copy link
Member

Choose a reason for hiding this comment

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

I didn't understand the fix.
The method says "some nodes don't have direct semantic meaning by themselves and so we need to bind a different node that does"
But I don't follow why addressOf would fall in that category.
Also, it is strange that addressOf would be the only expression that needs special treatment for casts here.

If we bind the addressOf, what is wrong with the resulting bound node? (you could share .Dump() info from that node to illustrate the problem)

Copy link
Member

Choose a reason for hiding this comment

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

As the comment says, when the bound tree involves an address of being the direct object of a cast, there is no boundnode for the address of in the tree at all. You have a BoundConversion, representing the (delegate*<void>)&C.M, and it's operand, a BoundMethodGroup representing C.M. Since there is no node in the tree for the &C.M itself, GetBoundNodes will do a fallback "there must be an error here" binding (

if (results.IsEmpty)
{
// https://github.com/dotnet/roslyn/issues/35038: We have to run analysis on this node in some manner
using (_nodeMapLock.DisposableWrite())
{
var boundNode = this.Bind(incrementalBinder, node, BindingDiagnosticBag.Discarded);
GuardedAddBoundTreeForStandaloneSyntax(node, boundNode);
results = GuardedGetBoundNodesFromMap(node);
}
if (!results.IsEmpty)
{
return results;
}
}
), resulting in a BoundUnconvertedAddressOf node that is marked as failing overload resolution.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. Your explanation was clearer than comment :-P

@jcouv jcouv self-assigned this Nov 11, 2025
@jcouv
Copy link
Member

jcouv commented Nov 11, 2025

There seems to be legitimate CI test failures

Does this PR close issue #81113 ?

jcouv
jcouv previously approved these changes Nov 11, 2025
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 5) modulo typo

@CyrusNajmabadi
Copy link
Member Author

i can't approve the PR, even though i didn't write the fix.

@CyrusNajmabadi
Copy link
Member Author

@333fred seems like we have some failures in tests like:

Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen.CodeGenFunctionPointersTests.AddressOf_CannotAssignToVoidStar

@333fred
Copy link
Member

333fred commented Nov 12, 2025

Yes, I'm aware. This is going to need to be a bigger change to the bound tree.

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.

3 participants