Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List patterns: x is [..var y] with a custom collection type causes a crash #59466

Closed
sa-exe opened this issue Feb 10, 2022 · 0 comments · Fixed by #59478
Closed

List patterns: x is [..var y] with a custom collection type causes a crash #59466

sa-exe opened this issue Feb 10, 2022 · 0 comments · Fixed by #59478
Assignees
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Feature - List Patterns

Comments

@sa-exe
Copy link

sa-exe commented Feb 10, 2022

Version Used: main (27 Jan 2022, 3b32fc3)

Steps to Reproduce:

using System;

var x = new S();
_ = x is [..var y];

struct S
{
  public int Length { get; }
  public int this[int i] => 42;
  public S this[Range r] => default;
}

Expected Behavior: the code compiles

Actual Behavior:

System.InvalidOperationException: This program location is thought to be unreachable.
   at Microsoft.CodeAnalysis.CSharp.Binder.MakeIsPatternExpression(SyntaxNode node, BoundExpression expression, BoundPattern pattern, TypeSymbol boolType, Boolean hasErrors, BindingDiagnosticBag diagnostics) in /_/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs:line 60
   at Microsoft.CodeAnalysis.CSharp.Binder.BindIsPatternExpression(IsPatternExpressionSyntax node, BindingDiagnosticBag diagnostics) in /_/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs:line 20
...

https://sharplab.io/#v2:EYLgtghglgdgNAFxAJwK7wCYgNQB8ACATAIwCwAUBQG4TIAEAHnQLx0wCmA7nQMoAUASgDcFAPotGdKAGc6AbQB0CmvQCeAXRGVy0hGgDGCXhQDeFOnXwBmKTCMAZdjADmCABZ0TdZ+wRC6AL7mljawRu4ycmFS6iwAfHQALIRaFta8dBHScgBKEC7sdMixzAkY7ABmEKgANn4UAUA==

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 10, 2022
@jcouv jcouv self-assigned this Feb 11, 2022
@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label Feb 11, 2022
@jcouv jcouv added the 4 - In Review A fix for the issue is submitted for review. label Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Feature - List Patterns
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants