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

Non-exhaustive switch expressions should be allowed #37

Open
RikkiGibson opened this issue Apr 19, 2021 · 3 comments
Open

Non-exhaustive switch expressions should be allowed #37

RikkiGibson opened this issue Apr 19, 2021 · 3 comments

Comments

@RikkiGibson
Copy link

RikkiGibson commented Apr 19, 2021

Take a simple scenario including a non-exhaustive switch expression:

int x = 0;
_ = x switch { 1 => 2 }; // warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '0' is not covered.

It looks like the type System.Runtime.CompilerServices.SwitchExpressionException needs to be explicitly allowed by Unbreakable for this to be allowed to run on SharpLab.

https://sharplab.io/#v2:EYLgtghglgdgNAFxAJwK7wCYgNQB9YIAEAHoQLyEAMA3ALABQA+uSYQM4DuUCAxgBaEA3oQCM5AHyEATIQC+dekA

@RikkiGibson
Copy link
Author

Ping :) would be happy to try and contribute the change if you could point me in the right direction.

@ashmind
Copy link
Owner

ashmind commented Jul 23, 2021

Thanks for reporting! Technically, you can add it to

private static void SetupSystemRuntimeCompilerServices(NamespacePolicy compilerServices) {

But practically, SharpLab is no longer using Unbreakable except in fallback flows (until container flows are more stable).
So your example code should already run in SharpLab, unless you hit a fallback scenario.

@ashmind
Copy link
Owner

ashmind commented Nov 13, 2021

Hi @RikkiGibson, just FYI this library is being deprecated (not closing any issues in case someone wants to contribute a fix years later, however unlikely that is). However this is no longer a problem for SharpLab specifically, the code should run fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants