Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
alrz committed Nov 12, 2021
1 parent 1a1e1b9 commit cb5efa4
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5596,6 +5596,36 @@ interface IInner
);
}

[Fact]
public void Subsumption_Slice_03()
{
var source = @"
using System;
Span<int> s = default;
switch (s) {
case [..[1],2,3]:
case [1,2,3]: // 1
break;
}
int[] a = default;
switch (a) {
case [..[1],2,3]:
case [1,2,3]: // 2
break;
}
";
var comp = CreateCompilationWithIndexAndRangeAndSpan(new[] { source, TestSources.GetSubArray }, options: TestOptions.DebugExe);
comp.VerifyEmitDiagnostics(
// (6,10): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [1,2,3]: // 1
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[1,2,3]").WithLocation(6, 10),
// (13,10): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [1,2,3]: // 2
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[1,2,3]").WithLocation(13, 10)
);
}

[Fact]
public void Exhaustiveness_01()
{
Expand Down

0 comments on commit cb5efa4

Please sign in to comment.