Hi,
After adding a the pre-condition below Code contracts crashes with the following message:
CodeContracts: RestWeb: Failed with uncaught exception: Should never happen
CodeContracts: RestWeb: Stack trace: at Microsoft.Research.CodeAnalysis.OptimisticHeapAnalyzer`8.EdgeRenaming(Pair`2 edge, Boolean joinPoint)
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.OptimisticHeapAnalyzer`8.ValueDriver`1.EdgeConversion(APC from, APC next, Boolean joinPoint, AState state)
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.ForwardAnalysisSolver`2.PushState(APC pc, APC next, AState state)
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.DFARoot`2.ComputeFixpoint()
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.ForwardDFA`2.Run(AState startState)
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.AnalysisDriver`10.MDriver..ctor(Method method, AnalysisDriver`10 parent)
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.AnalysisDriver`10.MethodDriver(Method method)
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.Clousot.TypeBinder`8.AnalyzeNonIteratorMethodInternal(Method method)
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.Clousot.TypeBinder`8.AnalyzeMethodInternal(Method method)
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.Clousot.TypeBinder`8.AnalyzeMethod(Method method)
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.Clousot.TypeBinder`8.AnalyzeAssembly(String assemblyName, Set`1 assembliesUnderAnalysis)
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.Clousot.TypeBinder`8.InternalAnalyze()
CodeContracts: RestWeb: at Microsoft.Research.CodeAnalysis.Clousot.TypeBinder`8.Analyze()
The method causing this is the following (removing the comment from the top-precondition causes the crash)
private static Node convertToNode(NodeRow nodeRow)
{
//Contract.Requires(nodeRow == null || (!string.IsNullOrEmpty(nodeRow.RowKey)));
//We return null iff nodeRow == null
Contract.Ensures((nodeRow == null) == (Contract.Result<Node>() == null));
if (nodeRow == null)
{
return null;
}
Node.Builder builder = Node.CreateBuilder().
SetId(nodeRow.RowKey.ToNodeID()).
SetUserId(nodeRow.UserID.ToUserID()).
SetAvailability(nodeRow.Availability).
SetName(nodeRow.Name);
return builder.Build();
}