分析代码时出现异常

Exception when analyzing code

在使用 PVS-Studio 6.18.23098 分析一些代码时,我在 PVS-Studio 中得到了以下堆栈跟踪 window:

Exception message:   0
 Sequence contains no elements  0
 Stack:    at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Utils.VariableValueInfo.VariableValueInfoWalker.GetJoinVariableValueInfo(SyntaxNode environmentNode, SyntaxNode node, VariableValueInfo prewVariableValueInfo, IEnumerable`1 lastVariableValueInfo, TypeRelationship typeRelationship) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Utils\VariableValueInfo.cs:line 1002  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Utils.VariableValueInfo.VariableValueInfoWalker.VisitConditionalExpression(ConditionalExpressionSyntax node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Utils\VariableValueInfo.cs:line 660  0
    at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Utils.VariableValueInfo.VariableValueInfoWalker.VisitAssignmentExpression(AssignmentExpressionSyntax node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Utils\VariableValueInfo.cs:line 553  0
    at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Utils.VariableValueInfo.VariableValueInfoWalker.VisitExpressionStatement(ExpressionStatementSyntax node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Utils\VariableValueInfo.cs:line 745  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Utils.VariableValueInfo.VariableValueInfoWalker.<>c__DisplayClass30_0.<VisitBlock>b__0() in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Utils\VariableValueInfo.cs:line 731  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Utils.VariableValueInfo.VariableValueInfoWalker.CommonFunctionForBlock(Ramification branch, Action action) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Utils\VariableValueInfo.cs:line 946  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Utils.VariableValueInfo.ParseFunction(SemanticModelAdapter model, SyntaxNode mainBlock) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Utils\VariableValueInfo.cs:line 433  0
    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.SemanticModelAdapter.GetVariableValueInfo(SyntaxNode node, Boolean includeLastAssignment) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\SemanticModelAdapter.cs:line 814  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Utils.SyntaxNodeUtils.IsImmutableStateMethod(SemanticModelAdapter model, InvocationExpressionSyntax invocationExpression) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Utils\SyntaxNodeUtils.cs:line 300  0
    at ProgramVerificationSystems.PVSStudio.Core.VirtualValues.VirtualValuesUtils.ResetChangedVariables(SemanticModelAdapter model, InvocationExpressionSyntax invocation, VirtualValuesContainer container) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\VirtualValues\VirtualValuesUtils.cs:line 122  0
    at ProgramVerificationSystems.PVSStudio.Core.VirtualValues.VirtualValuesUtils.ResetChangedVariables(SemanticModelAdapter model, ExpressionSyntax expression, VirtualValuesContainer container) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\VirtualValues\VirtualValuesUtils.cs:line 112  0
    at ProgramVerificationSystems.PVSStudio.Core.VirtualValues.VirtualValuesProcessor.AfterProcessInvocation(InvocationExpressionSyntax invocation) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\VirtualValues\VirtualValuesProcessor.cs:line 1352  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.CommonVisit(Type typeRuleBase, SyntaxNode node, Action`2 actionVisitRule, Action callBaseVisit, Func`1 virtualProcessorBeforeAction, Action`1 virtualProcessorAfterAction, VisibleVariablesContainer visibleDeclarations) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 270  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.VisitInvocationExpression(InvocationExpressionSyntax node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 1022  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.<>c__DisplayClass38_0.<Visit>b__1() in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 302  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.CommonVisit(Type typeRuleBase, SyntaxNode node, Action`2 actionVisitRule, Action callBaseVisit, Func`1 virtualProcessorBeforeAction, Action`1 virtualProcessorAfterAction, VisibleVariablesContainer visibleDeclarations) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 263  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.Visit(SyntaxNode node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 303  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.<>c__DisplayClass37_0.<DefaultVisit>b__1() in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 295  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.DefaultVisit(SyntaxNode node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 296  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.<>c__DisplayClass110_0.<VisitExpressionStatement>b__1() in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 819  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.VisitExpressionStatement(ExpressionStatementSyntax node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 822  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.<>c__DisplayClass62_0.<VisitBlock>b__1() in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 468  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.VisitBlock(BlockSyntax node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 476  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.<>c__DisplayClass149_0.<VisitMethodDeclaration>b__2() in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 1110  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.VisitMethodDeclaration(MethodDeclarationSyntax node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 1112  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.<>c__DisplayClass73_0.<VisitClassDeclaration>b__4() in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 568  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.VisitClassDeclaration(ClassDeclarationSyntax node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 570  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.<>c__DisplayClass153_0.<VisitNamespaceDeclaration>b__1() in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 1135  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.VisitNamespaceDeclaration(NamespaceDeclarationSyntax node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 1136  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.<>c__DisplayClass75_0.<VisitCompilationUnit>b__1() in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 581  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.VisitCompilationUnit(CompilationUnitSyntax node) in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 582  0
    at ProgramVerificationSystems.PVSStudio.Analyzer.Core.Walkers.CSharpRulesWalker.WalkFullTree() in D:\JenkinsProjects\Workspace\proj_PVS-Studio_Setup\WorkDir\PVS-Studio\PVS-Studio\Analyzer\Core\Walkers\CSharpRulesWalker.cs:line 76  0

我试图尽可能地减少代码,以获得一个最小的例子。 这是我能做的最小的例子,它激发了堆栈跟踪的出现。

class Class
{
    void MethodB(double value)
    {
        var a = 0;
        var b = 0;

        var (_, _) = (0 < 0) ? (a, b) : (b, a);
    }

    void MethodA(IInterface obj)
    {
        MethodB(obj.Property);
    }
}

interface IInterface
{
    double Property { get; }
}

这是已知错误吗?

请不要将 Whosebug 用作错误跟踪器。这违背了 Whosebug 的精神。请写信给我们支持类似的问题。

我把这个问题的描述给同事了。感谢您的信息。