dotnet / dotnet/roslyn

Wrong binder used in `SwitchExpressionBinder` logic

Open
#75,416 0 comments 0 reactions 0 assignees View on GitHub
Area-Compilers Concept-Design Debt
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

It is possible for the semantic model to add some more specific binders to the binder chain. But in `BindSwitchExpression` we call `BindSwitchExpressionCore` which walks the binder chain (with `.Next`) until a `SwitchExpressionBinder` is reached. That binder is then used to bind the operand.
But when binding expressions, we should be either using the original binder or one derived from the original binder using `GetBinder` (which gives the opportunity for binders injected by the semantic model to maintain themselves).

Contributor guide

Open the contributing guide

Research direction

Start at BindSwitchExpression and trace how BindSwitchExpressionCore walks the binder chain to SwitchExpressionBinder. Verify how the operand is bound and how GetBinder can preserve binders injected by the semantic model; done means the original or appropriately derived binder is used instead of the traversed binder.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.