From 297307549f890ded88380fe1fc17b8da963b0871 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Tue, 4 Mar 2025 13:10:33 -0800 Subject: [PATCH] [DebuggingTheCompiler] Add a note about using -debug-cycles to debug request evaluator cycles. --- docs/DebuggingTheCompiler.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/DebuggingTheCompiler.md b/docs/DebuggingTheCompiler.md index 02a69d5e45140..3180d890066d6 100644 --- a/docs/DebuggingTheCompiler.md +++ b/docs/DebuggingTheCompiler.md @@ -219,6 +219,26 @@ passing the flag `-Xfrontend -debug-constraints`: $ swift repl -Xfrontend -debug-constraints 1> let foo = 1 +### Debugging Evaluator Cycles + +When triggering code in the type checker, one can by mistake cause a cycle in +the request evaluator. The error looks as follows: + +``` +:0: error: circular reference +file.swift:18:22: note: through reference here +16 | +17 | extension MyType { +18 | public static func test() -> MyType { ... } + | `- note: through reference here +19 | } +20 | +``` + +To determine the actual circular request that is occuring, one can pass in the +flag `-debug-cycles` to the compiler which will cause the compiler to dump out +the linear chain of requests that led to the cycle. + ## Debugging on SIL Level ### Options for Dumping the SIL