dotnet / dotnet/roslyn

Debug assertion failure in MethodSymbol.AsMember when called from Binder.UnwrapCollectionExpressionIfNullable

Open
#73,181 0 comments 0 reactions 0 assignees View on GitHub
Area-Compilers Bug
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

`MethodSymbol.AsMember` assumes that the `newOwner` is not an error symbol. This can fail (cause a debug assertion) for the following caller:

https://github.com/dotnet/roslyn/blob/3f00cca15312e35225295d6f6ec68f8498538f8c/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs#L711

It seems like it should be sufficient to modify the following condition to also not take any action when `collectionExprType` is an error type:

https://github.com/dotnet/roslyn/blob/3f00cca15312e35225295d6f6ec68f8498538f8c/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs#L704

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.