-
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
Move reporting of ERR_IteratorMustBeAsync to avoid race condition #39990
Conversation
@@ -162,10 +161,6 @@ internal override TypeWithAnnotations GetIteratorElementType(YieldStatementSynta | |||
} | |||
elementType = TypeWithAnnotations.Create(CreateErrorType()); | |||
} | |||
else if (asyncInterface && !_methodSymbol.IsAsync) | |||
{ | |||
Error(elementTypeDiagnostics, ErrorCode.ERR_IteratorMustBeAsync, errorLocation, _methodSymbol, returnType); |
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.
Error(elementTypeDiagnostics, ErrorCode.ERR_IteratorMustBeAsync, errorLocation, _methodSymbol, returnType); [](start = 20, length = 107)
Can we get into similar trouble with errors reported above? #Closed
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.
I think so, yes. #39992 is indeed similar. I'll address in this PR. Thanks! #Resolved
Could you please check if #39992 is the same/similar issue? #Closed |
@@ -14594,6 +14594,7 @@ public static void Main() | |||
// public IEnumerator GetEnumerator() | |||
Diagnostic(ErrorCode.ERR_ReturnExpected, "GetEnumerator").WithArguments("C.GetEnumerator()") | |||
); | |||
comp.GetEmitDiagnostics(); |
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.
GetEmitDiagnostics [](start = 17, length = 18)
VerifyEmitDiagnostics? #Closed
It looks like this parameter is no longer used. #Closed Refers to: src/Compilers/CSharp/Portable/Binder/InMethodBinder.cs:127 in 10d359f. [](commit_id = 10d359f, deletion_comment = False) |
@@ -1897,6 +1898,7 @@ static System.Collections.Generic.IAsyncEnumerable<int> M() | |||
// static System.Collections.Generic.IAsyncEnumerable<int> M() | |||
Diagnostic(ErrorCode.ERR_IteratorMustBeAsync, "M").WithArguments("C.M()", "System.Collections.Generic.IAsyncEnumerable<int>").WithLocation(4, 61) | |||
); | |||
comp.GetEmitDiagnostics(); |
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.
GetEmitDiagnostics [](start = 17, length = 18)
VerifyEmitDiagnostics? #Closed
@@ -2244,6 +2245,8 @@ public static int Main() | |||
} | |||
}"; | |||
var compilation = CreateCompilation(text); | |||
compilation.GetDiagnostics(); |
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.
GetDiagnostics [](start = 24, length = 14)
Verify? #Closed
@@ -2244,6 +2245,8 @@ public static int Main() | |||
} | |||
}"; | |||
var compilation = CreateCompilation(text); | |||
compilation.GetDiagnostics(); | |||
compilation.GetEmitDiagnostics(); |
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.
GetEmitDiagnostics [](start = 24, length = 18)
Verify? #Closed
@@ -2244,6 +2245,8 @@ public static int Main() | |||
} | |||
}"; | |||
var compilation = CreateCompilation(text); | |||
compilation.GetDiagnostics(); |
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.
compilation.GetDiagnostics(); [](start = 12, length = 29)
Instead of modifying this particular unit-test, consider creating a new one. It looks like the original test is targeting specific sequence of API calls. #Closed
@@ -23,15 +23,13 @@ internal sealed class InMethodBinder : LocalScopeBinder | |||
|
|||
private class IteratorInfo |
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.
IteratorInfo [](start = 22, length = 12)
Can we use TypeWithAnnotations.Boxed
instead of this class now? #Closed
It's used in the override in In reply to: 558375087 [](ancestors = 558375087) Refers to: src/Compilers/CSharp/Portable/Binder/InMethodBinder.cs:127 in 10d359f. [](commit_id = 10d359f, deletion_comment = False) |
Would it make sense to move reporting of In reply to: 558389580 [](ancestors = 558389580,558375087) Refers to: src/Compilers/CSharp/Portable/Binder/InMethodBinder.cs:127 in 10d359f. [](commit_id = 10d359f, deletion_comment = False) |
It feels like we can get rid of this parameter as well. #Closed Refers to: src/Compilers/CSharp/Portable/Binder/InMethodBinder.cs:127 in 10d359f. [](commit_id = 10d359f, deletion_comment = False) |
Done with review pass (iteration 3) #Closed |
@@ -13,27 +13,15 @@ namespace Microsoft.CodeAnalysis.CSharp | |||
/// <summary> | |||
/// A binder for a method body, which places the method's parameters in scope | |||
/// and notes if the method is an iterator method. | |||
/// Note: instances of this type can be re-used across different attempts at compiling the same method (caching by binder factory). |
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.
Note [](start = 8, length = 4)
📝 I didn't find any other diagnostics stored in this binder.
@@ -261,7 +265,8 @@ private BoundStatement BindYieldBreakStatement(YieldStatementSyntax node, Diagno | |||
Error(diagnostics, ErrorCode.ERR_YieldNotAllowedInScript, node.YieldKeyword); | |||
} | |||
|
|||
GetIteratorElementType(node, diagnostics); | |||
ValidateYield(node, diagnostics); | |||
GetIteratorElementType(); |
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.
GetIteratorElementType(); [](start = 12, length = 25)
It looks like this call is not necessary now. #Closed
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 (iteration 5)
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.
…ointers * dotnet/master: (197 commits) Update dependencies from https://github.com/dotnet/arcade build 20191201.1 (dotnet#40084) Update list of C# Next features and reviewers (dotnet#39987) Update dependencies from https://github.com/dotnet/arcade build 20191130.1 (dotnet#40075) [master] Update dependencies from dotnet/arcade (dotnet#40065) Update dependencies from https://github.com/dotnet/arcade build 20191127.4 (dotnet#40057) Added more tests & fixed minor bug Deterministic ordering + added tests back Update dependencies from https://github.com/dotnet/arcade build 20191126.2 (dotnet#40036) removed a test due to random order generation Always restore when running a bootstrap build (dotnet#40025) fixed integration test capitalization for extract method and extract interface Fix tests pt2 DiagnosticIncrementalAnalyzer refactoring (dotnet#39956) Persistence is always available in OOP Update src/Workspaces/Core/Portable/SolutionSize/SolutionSizeTracker.cs Fixed tests Move reporting of iterator diagnostics to avoid race condition (dotnet#39990) Update dependencies from https://github.com/dotnet/arcade build 20191125.7 (dotnet#40020) Fix NGEN priority of csc.exe, vbc.exe, csi.exe (dotnet#40016) Accidentally deleted something ...
Fixes #39970
Fixes #39992