Skip to content

IDE crashes when writing is pattern in front of relational pattern #44398

@jhinder

Description

@jhinder

Version Used: VS 16.7P1 (Compiler version: '3.7.0-1.20257.3 (4b5650e5)'. Language version: preview.)

Steps to Reproduce:

Take the following code:

object M(int a)
{
    if ($$ a is > 0 and < 500) ;
}

Type "a is" at the marked location.

Expected Behavior: The IDE does not crash.

Actual Behavior: The IDE crashes.

Stack trace:

System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Microsoft.CodeAnalysis.ConstantValue.get_BooleanValue()
   at Microsoft.CodeAnalysis.CSharp.ValueSetFactory.BoolValueSetFactory.Microsoft.CodeAnalysis.CSharp.IValueSetFactory.Related(BinaryOperatorKind relation, ConstantValue value)
   at Microsoft.CodeAnalysis.CSharp.DecisionDagBuilder.MakeTestsAndBindingsForRelationalPattern(BoundDagTemp input, BoundRelationalPattern rel, BoundDagTemp& output)
   at Microsoft.CodeAnalysis.CSharp.DecisionDagBuilder.MakeTestsAndBindings(BoundDagTemp input, BoundPattern pattern, BoundDagTemp& output, ArrayBuilder`1 bindings)
   at Microsoft.CodeAnalysis.CSharp.DecisionDagBuilder.MakeTestsAndBindingsForBinaryPattern(BoundDagTemp input, BoundBinaryPattern bin, BoundDagTemp& output, ArrayBuilder`1 bindings)
   at Microsoft.CodeAnalysis.CSharp.DecisionDagBuilder.MakeTestsAndBindings(BoundDagTemp input, BoundPattern pattern, BoundDagTemp& output, ArrayBuilder`1 bindings)
   at Microsoft.CodeAnalysis.CSharp.DecisionDagBuilder.MakeAndSimplifyTestsAndBindings(BoundDagTemp input, BoundPattern pattern, ImmutableArray`1& bindings)
   at Microsoft.CodeAnalysis.CSharp.DecisionDagBuilder.CreateDecisionDagForIsPattern(SyntaxNode syntax, BoundExpression inputExpression, BoundPattern pattern, LabelSymbol whenTrueLabel)
   at Microsoft.CodeAnalysis.CSharp.Binder.MakeIsPatternExpression(SyntaxNode node, BoundExpression expression, BoundPattern pattern, TypeSymbol boolType, Boolean hasErrors, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindIsPatternExpression(IsPatternExpressionSyntax node, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node, DiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node, DiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindBooleanExpression(ExpressionSyntax node, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindIfStatement(IfStatementSyntax node, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindBlockParts(BlockSyntax node, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindBlock(BlockSyntax node, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodBody(CSharpSyntaxNode declaration, BlockSyntax blockBody, ArrowExpressionClauseSyntax expressionBody, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodBody(CSharpSyntaxNode syntax, DiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.BindMethodBody(MethodSymbol method, TypeCompilationState compilationState, DiagnosticBag diagnostics, ImportChain& importChain, Boolean& originalBodyNested, InitialState& forSemanticModel)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.VisitNamedType(NamedTypeSymbol symbol, TypeCompilationState arg)
   at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.Accept[TArgument,TResult](CSharpSymbolVisitor`2 visitor, TArgument argument)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamespace(NamespaceSymbol symbol)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.VisitNamespace(NamespaceSymbol symbol, TypeCompilationState arg)
   at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TArgument,TResult](CSharpSymbolVisitor`2 visitor, TArgument argument)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamespace(NamespaceSymbol symbol)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethodBodies(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuiltOpt, Boolean emittingPdb, Boolean emitTestCoverageData, Boolean hasDeclarationErrors, DiagnosticBag diagnostics, Predicate`1 filterOpt, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetDiagnosticsForMethodBodiesInTree(SyntaxTree tree, Nullable`1 span, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetDiagnosticsForSyntaxTree(CompilationStage stage, SyntaxTree syntaxTree, Nullable`1 filterSpanWithinTree, Boolean includeEarlierStages, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.SyntaxTreeSemanticModel.GetDiagnostics(Nullable`1 span, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.GenerateCompilationEvents(AnalysisScope analysisScope, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.<ComputeAnalyzerDiagnosticsAsync>d__55.MoveNext()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions