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

Pattern Matching in While Loop #43984

Closed
ChayimFriedman2 opened this issue May 5, 2020 · 1 comment
Closed

Pattern Matching in While Loop #43984

ChayimFriedman2 opened this issue May 5, 2020 · 1 comment

Comments

@ChayimFriedman2
Copy link

Version Used: 8

Steps to Reproduce:
Type the following code and try to compile:

object o = 8;
while (!(o is int i)) { }
Console.WriteLine(i);

Expected Behavior: The code will emit a loop that run until o is int, then converts it to int as variable i. Just like pattern matching with if:

object o = 8;
if (!(o is int i)) { }
Console.WriteLine(i);

Actual Behavior: The code isn't compiled and strangely the scope of i is inside the loop, instead of outside it.

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

No branches or pull requests

3 participants