dotnet / dotnet/roslyn

LocalStateTracing: hoisted parameter reported to `LogParameterStore` as parameter instead of field only when entering block

Open
#79,703 0 comments 0 reactions 0 assignees View on GitHub
Area-Compilers Ongoing-Quality-Candidate
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

In `LocalStateTracingInstrumenter.InstrumentBlock`, we report the state of parameters using `LogParameterStore`.
In that scenario, the parameter is always reported by its ordinal.
We also record parameters with `LogParameterStore` when it is assigned directly or via method return. But those other scenarios report using a `BoundParameterId`, which means that we'll either emit the parameter's ordinal or, in the case when the parameter is hoisted, the field's ordinal.
See logic in `EmitParameterIdExpression`.

This seems inconsistent for consumers of the logged information. We should probably also use a `BoundParameterId` in the call to `LogParameterStore` in `LocalStateTracingInstrumenter.InstrumentBlock`.

Relates to https://github.com/dotnet/roslyn/pull/79557#discussion_r2244302242

Contributor guide

Open the contributing guide

Research direction

Start in LocalStateTracingInstrumenter.InstrumentBlock and compare its LogParameterStore call with the other call sites that use EmitParameterIdExpression. Trace how a BoundParameterId is converted for hoisted and non-hoisted parameters, then verify that block-entry logging reports the field ordinal for hoisted parameters and the parameter ordinal otherwise.

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
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.