Repository navigation
Name uniquify scopes after statements, not positions (#1303) - #1312
Merged
Merged
Conversation
uniquify_deduce gave each top-level statement the scope s<index>_, so inserting or deleting a statement renamed every statement after it and both per-statement caches missed on all of them. The segment is now <len><name><count>_ (the keyword for an unnamed statement), so the others keep their names. Removing a statement used to invalidate everything after it as a side effect, which hid that the check_proofs cache did not treat (and views, , ...) as barriers. Every statement that is not a plain named definition is now a barrier for both caches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jsiek
marked this pull request as ready for review
November 20, 2026 15:44
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1303.
Example
The issue's repro, three theorems and then a new theorem added at the top:
The bound variable
pPintheorem t1used to bepP.s0_1. It is nowpP.2t1_1wherevert1sits in the file.Changes
abstract_syntax/ops.py:uniquify_deducenames each statement's scope segment after the statement, not its index (_statement_scope). The segment is<len><key><count>_, where:assert,print, ...), which can't collide with identifiers;assertstatements are6assert_and6assert1_;import).checker_cache.py: every statement that is not a plain named definition (_NAME_ONLY_STATEMENTS) is now a barrier for thecheck_proofscache too, as it already was for the type-check cache.test/lsp/test_warm_check.py::test_user_inductive_does_not_leak_into_later_checks: deletinginductive TwoList by tl_inductionleft the theorem that relies on it a cache hit, becauseInductivewasn't a barrier. Views andassociativewere in the same position.Fixtures
Regenerated the ones that print unique names:
test/should-error/givens_assume_no_prem_not_ifthen.pf.err(q.s0_3becameq.1T_3). That message shouldn't show a unique name at all; filed as Error message shows a uniquified label: "not a proof of if-then: assume q.s0_3{?}" #1311.test/compile/lower/*.{ir,cir,pir}, withrun_lower.py --regenerate.Tests
test/lsp/test_check_proofs_cache.py: inserting or deleting a theorem leaves the others hits.test/lsp/test_uniquify_determinism.py: the scope test now uses the new segments, plus a new test that inserting a statement keeps the others' names and that twoasserts get distinct scopes.make static,test-deduce.pyandpytest test/lsp test/unit(1321 passed) all pass.make tests-compilefails onmainand on this branch in the same three places. All are already tracked:source_map.pf(#1309),ViewDecl(#1211) andConceptDecl(#1292).run_lower.pypasses apart fromsource_map.pf, andrun_separate.pypasses.🤖 Generated with Claude Code