Skip to content

Commit 73c3128

Browse files
haasonsaasclaude
andauthored
fix: Catch all exceptions from _run_lean to prevent UnboundLocalError (#4)
If _run_lean raises something other than TimeoutExpired (e.g. UnicodeDecodeError from non-UTF-8 lean output), the result variable was unbound, crashing at cache.put() and return. Now catches all exceptions with an INCONCLUSIVE result. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e861fa8 commit 73c3128

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

formal_verification/lean_prover.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,18 @@ def prove_specification(self, spec: FormalSpec) -> ProofResult:
124124
prover_name="lean",
125125
solver_status=ProofStatus.TIMEOUT.value,
126126
)
127+
except Exception as exc:
128+
logger.error("Lean proof attempt failed: %s", exc)
129+
result = ProofResult(
130+
spec=spec,
131+
proven=False,
132+
proof_time_ms=(time.time() - start_time) * 1000,
133+
error_message=str(exc),
134+
counter_example=None,
135+
proof_output="",
136+
prover_name="lean",
137+
solver_status=ProofStatus.INCONCLUSIVE.value,
138+
)
127139

128140
if self.use_cache and self.cache:
129141
self.cache.put(spec, result)

0 commit comments

Comments
 (0)