We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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:
o
int
i
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.
The text was updated successfully, but these errors were encountered:
This behavior is intentional:
#15529 https://github.com/dotnet/csharplang/blob/master/meetings/2016/LDM-2016-11-30.md#scope-of-while-condition-expression-variables
Sorry, something went wrong.
No branches or pull requests
Version Used: 8
Steps to Reproduce:
Type the following code and try to compile:
Expected Behavior: The code will emit a loop that run until
o
isint
, then converts it toint
as variablei
. Just like pattern matching withif
:Actual Behavior: The code isn't compiled and strangely the scope of
i
is inside the loop, instead of outside it.The text was updated successfully, but these errors were encountered: