Skip to content

Commit d199fc3

Browse files
committed
Fix infinite recursion
1 parent ec4f742 commit d199fc3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/ThrowsAnalyzer/Analysis/ExceptionPropagationTracker.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ public async Task<ExceptionFlowInfo> AnalyzeMethodAsync(IMethodSymbol method)
3535

3636
var flowInfo = new ExceptionFlowInfo(method);
3737

38+
// Add placeholder to cache immediately to prevent infinite recursion
39+
// in case of circular method calls
40+
_cache[method] = flowInfo;
41+
3842
// Find the method's syntax node
3943
var syntaxReferences = method.DeclaringSyntaxReferences;
4044
if (!syntaxReferences.Any())
4145
{
42-
_cache[method] = flowInfo;
4346
return flowInfo;
4447
}
4548

@@ -59,9 +62,6 @@ public async Task<ExceptionFlowInfo> AnalyzeMethodAsync(IMethodSymbol method)
5962
// 4. Calculate propagated exceptions (thrown - caught)
6063
CalculatePropagatedExceptions(flowInfo, semanticModel);
6164

62-
// Cache the result
63-
_cache[method] = flowInfo;
64-
6565
return flowInfo;
6666
}
6767

0 commit comments

Comments
 (0)