dotnet / dotnet/roslyn

CodeGenerator.HasHome most likely lacking proper handling for `RefKindExtensions.StrictIn`

Open
#84,486 1 comment 1 reaction 2 assignees Claimed by @AlekseyTs View on GitHub
Area-Compilers Concept-Design Debt
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

I was experimenting with a fix for #84344 and ran into an incorrect behavior for `BoundDup` with `RefKind == RefKindExtensions.StrictIn`. I would expect the result of the function be true when ```IsAnyReadOnly(addressKind)```. Local rewriter creates `LocalSymbol`s with such `RefKind` and this is how we ended up with `BoundDup` with such `RefKind` during my experiment. Note, that it looks like the function has similar issue with `BoundLocal` nodes. However, a quick attempt to adjust the code for `BoundLocal` resulted to several test breaks in `ExtensionIndexersTests` and `ExtensionTests`.

I think my intuition about behavior of `CodeGenerator.HasHome` is correct, but it looks like we might have improper handling elsewhere.

We also should check other places where `RefKind.RefREadonly` is treated specially but `RefKindExtensions.StrictIn` isn't.

Alternatively, we can evaluate a possibility of getting rid of `RefKindExtensions.StrictIn` value and find a different way to represent the desired semantics without using a special internal `RefKind` value. Or, perhaps, we should never use it for a `LocalSymbol`.

Bottom line, more investigation is necessary here.

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.