Skip to content

fix(py-lsp): cap expression evaluation depth#758

Open
SyntaxSawdust wants to merge 1 commit into
DeusData:mainfrom
SyntaxSawdust:codex/issue-720-py-lsp-depth
Open

fix(py-lsp): cap expression evaluation depth#758
SyntaxSawdust wants to merge 1 commit into
DeusData:mainfrom
SyntaxSawdust:codex/issue-720-py-lsp-depth

Conversation

@SyntaxSawdust

Copy link
Copy Markdown

Summary

  • Add a Python expression-evaluation depth guard with graceful unknown fallback.
  • Track evaluator recursion depth in PyLSPContext.
  • Add a fork-protected regression for deeply nested Python expressions.

Why

Fixes #720.

Python was missing the eval-depth protection already present in sibling LSP implementations. Deeply nested Python expressions now stop at a bounded depth instead of continuing recursive type evaluation indefinitely.

Tests

  • build/c/test-runner stack_overflow - passed, 14 tests.
  • build/c/test-runner py_lsp py_lsp_stress - passed, 102 tests.
  • git diff --check - passed.

Scope

  • No redesign of Python type inference or call resolution.
  • No changes to other language LSP caps.
  • Full test/lint were not rerun; local broad proof is environment/tooling-limited as noted above.

Signed-off-by: Dustin Persek <dustin.persek@protonmail.com>
@SyntaxSawdust SyntaxSawdust marked this pull request as ready for review July 2, 2026 04:13
@SyntaxSawdust SyntaxSawdust requested a review from DeusData as a code owner July 2, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

py_lsp: py_eval_expr_type infinite recursion — Python missed in 9f981a1 depth-guard fix

1 participant