Skip to content
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

System.InvalidOperationException: Unexpected value 'UnboundLambda' of type 'Microsoft.CodeAnalysis.CSharp.BoundKind' #31370

Closed
TessenR opened this issue Nov 26, 2018 · 2 comments

Comments

@TessenR
Copy link

TessenR commented Nov 26, 2018

Version Used:

Branch C# 8.0: Nullable reference type (29 Oct 2018)
https://github.com/dotnet/csharplang/blob/master/proposals/nullable-reference-types.md
Latest commit 2f8fef by AlekseyTs:
Compare Nullable modifiers while comparing type symbols by default. (#30770)

Steps to Reproduce:

Compile the following code:

#nullable enable
class C
{
    static void Main()
    {
        System.Action a = null!;
        a = () => { }!;
    }
}

https://sharplab.io/#v2:EYLgZgpghgLgrgJwgZwLQDk4BstWFiAJQkiQDsBjCAFQE8AHFAGgBMQBqAHwGIztd8EAAQQyeAgFgAUAAEATEIDC0gN7ShGoTICMANi0AWIQFkoASzIAKAJTrNaqZqdbtAOh0KoQgLxC+OAEIAbjtnIS9fGx8APiEVIQBfYNDE6QSgA=

Actual Behavior:

System.InvalidOperationException: Unexpected value 'UnboundLambda' of type 'Microsoft.CodeAnalysis.CSharp.BoundKind' at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(BoundExpression expression, Boolean used) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitExpression.cs:line 323 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitExpression.cs:line 59 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitConversionExpression(BoundConversion conversion, Boolean used) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitConversion.cs:line 40 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(BoundExpression expression, Boolean used) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitExpression.cs:line 115 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitExpression.cs:line 59 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitAssignmentValue(BoundAssignmentOperator assignmentOperator) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitExpression.cs:line 2447 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitAssignmentExpression(BoundAssignmentOperator assignmentOperator, UseKind useKind) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitExpression.cs:line 2052 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(BoundExpression expression, Boolean used) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitExpression.cs:line 91 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCoreWithStackGuard(BoundExpression expression, Boolean used) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitExpression.cs:line 75 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitExpression.cs:line 63 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement(BoundStatement statement) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitStatement.cs:line 42 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementAndCountInstructions(BoundStatement statement) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitStatement.cs:line 103 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitSequencePointStatement(BoundSequencePoint node) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\CodeGenerator.cs:line 353 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement(BoundStatement statement) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitStatement.cs:line 34 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(ImmutableArray`1 statements) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitStatement.cs:line 648 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(BoundBlock block) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitStatement.cs:line 615 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement(BoundStatement statement) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitStatement.cs:line 26 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementList(BoundStatementList list) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitStatement.cs:line 109 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement(BoundStatement statement) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\EmitStatement.cs:line 46 at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.GenerateImpl() in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\CodeGen\CodeGenerator.cs:line 258 at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(PEModuleBuilder moduleBuilder, MethodSymbol method, Int32 methodOrdinal, BoundStatement block, ImmutableArray`1 lambdaDebugInfo, ImmutableArray`1 closureDebugInfo, StateMachineTypeSymbol stateMachineTypeOpt, VariableSlotAllocator variableSlotAllocatorOpt, DiagnosticBag diagnostics, DebugDocumentProvider debugDocumentProvider, ImportChain importChainOpt, Boolean emittingPdb, Boolean emitTestCoverageData, ImmutableArray`1 dynamicAnalysisSpans) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\Compiler\MethodCompiler.cs:line 1428 at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\Compiler\MethodCompiler.cs:line 1196 at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\Compiler\MethodCompiler.cs:line 498 at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass21_0.<CompileNamedTypeAsTask>b__0() in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\Compiler\MethodCompiler.cs:line 388 at Roslyn.Utilities.UICultureUtilities.<>c__DisplayClass5_0.<WithCurrentUICulture>b__0() in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\Core\Portable\InternalUtilities\UICultureUtilities.cs:line 136 at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.WaitForWorkers() in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\Compiler\MethodCompiler.cs:line 303 at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethodBodies(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuiltOpt, Boolean emittingPdb, Boolean emitTestCoverageData, Boolean hasDeclarationErrors, DiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\Compiler\MethodCompiler.cs:line 144 at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CompileMethods(CommonPEModuleBuilder moduleBuilder, Boolean emittingPdb, Boolean emitMetadataOnly, Boolean emitTestCoverageData, DiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\CSharp\Portable\Compilation\CSharpCompilation.cs:line 2626 at Microsoft.CodeAnalysis.Compilation.Emit(Stream peStream, Stream metadataPEStream, Stream pdbStream, Stream xmlDocumentationStream, Stream win32Resources, IEnumerable`1 manifestResources, EmitOptions options, IMethodSymbol debugEntryPoint, Stream sourceLinkStream, IEnumerable`1 embeddedTexts, CompilationTestData testData, CancellationToken cancellationToken) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\Core\Portable\Compilation\Compilation.cs:line 2387 at Microsoft.CodeAnalysis.Compilation.Emit(Stream peStream, Stream pdbStream, Stream xmlDocumentationStream, Stream win32Resources, IEnumerable`1 manifestResources, EmitOptions options, IMethodSymbol debugEntryPoint, Stream sourceLinkStream, IEnumerable`1 embeddedTexts, Stream metadataPEStream, CancellationToken cancellationToken) in D:\$TC\work\142fd509662c8cdc\!roslyn\sources\dotnet\src\Compilers\Core\Portable\Compilation\Compilation.cs:line 2335 at SharpLab.Server.Compilation.Compiler.<TryCompileToStreamAsync>d__1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at SharpLab.Server.MirrorSharp.SlowUpdate.<ProcessAsync>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at MirrorSharp.Internal.Handlers.SlowUpdateHandler.<ExecuteAsync>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at MirrorSharp.Internal.Connection.<ReceiveAndProcessInternalAsync>d__13.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at MirrorSharp.Internal.Connection.<ReceiveAndProcessAsync>d__12.MoveNext()
@jcouv
Copy link
Member

jcouv commented Jan 3, 2019

Thanks @TessenR
There is a class of similar bugs around !. It should behave transparently, just like parentheses. I'm working on a general solution that should solve the entire class of bugs.

@jcouv jcouv modified the milestones: 16.0, 16.1 Mar 18, 2019
@jcouv
Copy link
Member

jcouv commented Mar 18, 2019

Was fixed by #32850 (represents suppression as flag in bound tree)

@jcouv jcouv closed this as completed Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants