-
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
Compiler crash with recursive local function parameter default value #16451
Comments
I'm surprise it even compiles, as the default value part of the optional parameter requires a compile-time constant. |
@AdamSpeight2008 It doesn't compile without an error. The compiler crashes before it has a chance to produce the error. |
See https://github.com/dotnet/roslyn/pull/16315/files#r95429886 for a conversation that may be related to this. |
@gafter I was saying that it shouldn't even compile. To me it sounds like it trying to see if the result of the |
@AdamSpeight2008 Agreed, it should not even compile. But the compiler should terminate nicely after printing a nice, friendly error message rather than crashing. |
@gafter So is failing to parse? or Bind? |
@AdamSpeight2008 Binding is failing in non-terminating recursion. In essence, when |
Local function parameters seemed to be designed to bind their parameters' default values eagerly, as opposed to methods which bind their default values lazily. This creates the possibility of infinite binder recursion if the default value mentions the local function itself (which has yet to be fully bound). Fixes dotnet#16451
Current strict binding can cause circularity problems when local functions are referenced. This change causes local functions to use lazy default parameter binding, similar to methods, and then forces their construction when diagnostics are requested for the local function. This also requires a mechanism for recording declaration diagnostics outside of adding to the compilation's DeclarationDiagnostics. A new type, DeclarationDiagnosticStore is introduced as an abstraction to store declaration diagnostics on either the compilation or in a local DiagnosticBag, depending on the needs of the symbol storing diagnostics. Fixes dotnet#16451
Make local function default parameter value binding lazy Current strict binding can cause circularity problems when local functions are referenced. This change causes local functions to use lazy default parameter binding, similar to methods, and then forces their construction when diagnostics are requested for the local function. This also requires a mechanism for recording declaration diagnostics outside of adding to the compilation's DeclarationDiagnostics. A new type, DeclarationDiagnosticStore is introduced as an abstraction to store declaration diagnostics on either the compilation or in a local DiagnosticBag, depending on the needs of the symbol storing diagnostics. Fixes #16451, #17293
@agocke Randomly stumbled upon a skipped test due to this issue: |
Typing the following code into a C# project causes VS to crash (stack overflow in the compiler).
The text was updated successfully, but these errors were encountered: