-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Allow ref enumerators in async/iterator methods #74800
Conversation
fc2395c
to
f72e4b2
Compare
f72e4b2
to
05aa011
Compare
@dotnet/roslyn-compiler for reviews, thanks |
); | ||
|
||
comp2 = CreateCompilation(src1 + src2, targetFramework: s_targetFrameworkSupportingByRefLikeGenerics, parseOptions: TestOptions.Regular12); | ||
comp2.VerifyEmitDiagnostics( | ||
// (14,24): error CS9202: Feature 'ref struct interfaces' is not available in C# 12.0. Please use language version 13.0 or greater. | ||
// public ref struct S2 : IAsyncDisposable | ||
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion12, "IAsyncDisposable").WithArguments("ref struct interfaces", "13.0").WithLocation(14, 24), | ||
// (40,15): error CS8344: foreach statement cannot operate on enumerators of type 'S2' in async or iterator methods because 'S2' is a ref struct or a type parameter that allows ref struct. | ||
// (40,15): error CS9202: Feature 'ref and unsafe in async and iterator methods' is not available in C# 12.0. Please use language version 13.0 or greater. |
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.
Diagnostic clarity and not directly related to this PR: is it intentional that when we report the LangVer error we no longer report CS4007?
This seems rather unfriendly (user gets a bad surprise after following our advice to upgrade LangVer).
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.
Yes, that's a pre-existing issue. The CS4007 is reported during emit, so we never get to report it when we report other binding-time errors. It's also a pre-existing error (so we cannot replace it with a LangVersion error) but perhaps we could detect just the new scenarios and report a LangVersion error for them in the emit phase instead (I'm not sure how feasible that would be).
(Btw, there is also a tracking issue for a similar problem for unsafe
: #73280 - it's part of the same feature but the issue currently only talks about different diagnostics.)
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.
LGTM Thanks (iteration 3)
@cston @dotnet/roslyn-compiler for second review. Thanks |
1 similar comment
@cston @dotnet/roslyn-compiler for second review. Thanks |
Fixes #74793.
Related to test plan #72662.