-
Notifications
You must be signed in to change notification settings - Fork 4k
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
C#7 inline As variable scope is too wide #19129
Comments
The behavior you are observing is actually by design. It was implemented in order to support common scenarios like this: if (!(e is ArgumentException ae))
{
return;
}
// do something with ae here 📝 Note that I wasn't part of the design for this feature. I'm simply telling you how the outcome of the language design team's work on this feature relates to the behavior you observed. |
I'm leaving this open so one of the language design members can add more context and/or links to related issues to help you understand how to best use this new feature. 😄 |
This is indeed by design. I'll go ahead and close this. Thanks |
Versions Used:
2.1.0 (nuget from 24-04-2017),
Release version from
Internal ID: Roslyn-Signed_20170320.4
Internal VS ID: d15rel.26403.00
Steps to Reproduce:
https:/dotnet/roslyn/releases/tag/Visual-Studio-2017-Update-1
Expected Behavior:
Build should have pass.
This construct should be treated like
Actual Behavior:
Microsoft (R) Visual C# Compiler version 2.1.0.56735
Copyright (C) Microsoft Corporation. All rights reserved.
test.cs(15,17): error CS0128: A local variable or function named 'ae' is already defined in thi
s scope
Code is treated like
The text was updated successfully, but these errors were encountered: