-
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
Disallow modifiers in local_using_declaration #72589
Conversation
src/Compilers/CSharp/Test/Semantic/Semantics/UsingDeclarationTests.cs
Outdated
Show resolved
Hide resolved
@dotnet/roslyn-compiler for a second review. Thanks |
@@ -7902,4 +7902,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ | |||
<data name="ERR_ParamsCollectionMissingConstructor" xml:space="preserve"> | |||
<value>Non-array params collection type must have an applicable constructor that can be called with no arguments.</value> | |||
</data> | |||
<data name="ERR_NoModifiersOnUsing" xml:space="preserve"> | |||
<value>Modifiers cannot be placed on resource declarations</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// (1,39): error CS1002: ; expected | ||
// using (const var obj2 = new object()) { } | ||
Diagnostic(ErrorCode.ERR_SemicolonExpected, "{").WithLocation(1, 39)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
cases are tested in ModifiersInUsingLocalDeclarations_Const
and ModifiersInUsingLocalDeclarations_Const_Async
Never mind, you meant with an explicit type... Sorry for the confusion
// (1,44): error CS1002: ; expected | ||
// await using (const var obj = new object()) { } | ||
Diagnostic(ErrorCode.ERR_SemicolonExpected, "{").WithLocation(1, 44)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
void M() | ||
{ | ||
using const System.IAsyncDisposable obj = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the cases in this test should be IDisposable
rather than IAsyncDisposable
.
Fixes #72496