dotnet / dotnet/roslyn

Temporaries generated by LocalRewriter for collection expression spans should be marked as long-lived

Open
#73,246 1 comment 0 reactions 0 assignees View on GitHub
Area-Compilers Bug Feature - Collection Expressions
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

The temporaries generated by `LocalRewriter` for collection expression spans are created at the outermost scope of the method and span multiple statements or sequence points, and therefore should be considered *long-lived* locals.

Currently however, the temporaries are created with `SynthesizedLocalKind.LoweringTemp`, for which `SynthesizedLocalExtensions.IsLongLived(kind)` returns `false`.

The fact that the temp locals are not considered long-lived may cause issues for the following:
- EnC which matches locals across method versions
- `SpillSequenceSpiller` which rewrites locals that are not long-lived (although currently `ref struct` instances cannot be used across `await`)

*Based on [comment](https://github.com/dotnet/roslyn/pull/73086#discussion_r1580213611) and discussion with @AlekseyTs.*

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.