-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
using System;
public class C
{
static int M()
{
return F() switch
{
1 => F() switch
{
C { P: int p, Q: C { P: int q } } => G(() => p + q),
_ => 10
},
C { Q: int s } => G(() => s),
_ => 0
};
}
object P { get; set; }
object Q { get; set; }
static object F() => null;
static int G(Func<int> f) => 0;
}PDB contains sequence points
<sequencePoints>
<entry offset="0x0" startLine="5" startColumn="5" endLine="5" endColumn="6" document="1" />
<entry offset="0x1" hidden="true" document="1" />
<entry offset="0x5b" hidden="true" document="1" />
<entry offset="0x118" startLine="16" startColumn="5" endLine="16" endColumn="6" document="1" />
</sequencePoints>The one at offset 0x5b shouldn't be emitted since it's in the middle of expression evaluation:
IL_005b: newobj instance void C/'<>c__DisplayClass0_1'::.ctor()
If we decide to merge closure scopes of the nested switch expressions to fix #37232, this issue will be resolved as well. If we decide to keep both closures then we need to avoid emitting the hidden sequence point on the inner one.
See test PDBTests.Patterns_SwitchExpression_Closures.
As it turns out, the outer hidden sequence point is also problematic: see #37261
Reactions are currently unavailable