fix(language): a file whose terms read each other's sums is refused at load - #780
Merged
Merged
Conversation
…t load A term that reads its own sum through another term of the same file loaded alone and failed only at merge, as a circular-reference cascade. The per-file check now follows the file's terms, and names the sums the loop runs through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AzXL2w5xdUm8FsYMNWf1KW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AzXL2w5xdUm8FsYMNWf1KW
FBumann
pushed a commit
that referenced
this pull request
Sep 29, 2026
#780 refuses a file whose terms read each other's sums. Under `adds_to:` one file may add several terms to one sum, so `_terms` groups the terms by the sum they add to, and `_loop` follows each term's reads through those groups. The direct self-read is the loop of length one, and keeps its message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AzXL2w5xdUm8FsYMNWf1KW
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.
Note
The following content was generated by AI.
A file whose terms read each other's sums loaded alone and failed only at merge. It is now refused at load, and the message names the sums the loop runs through.
What this changes
lowerresolves every term of a file first. Then_loopfollows each term's reads through the file's other terms. A term that reads its own sum, directly or through another term, is refused withGiven expression 's1': its term 'a' reads 's1', the sum the term adds to, through 's2', so the sum would define itself.The direct self-read keeps its message, without thethroughclause.Why
Finding 5 of the review of #763. One file with
s1: {term: a},s2: {term: b},a: p + s2andb: p + s1passedto_spec.mergethen failed with acircular expression referencecascade that named neither the file nor the rewrite. The file alone decides this, so the load decides it.Method, gate output, alternatives
Reproduced on
origin/main(9ace314) before the change:to_spec(f)loads, andmerge([owner, f])fails withNamed expression 's1': named expression 'a' does not load….Test first.
two-terms-reading-each-other-s-sumintest_what_a_term_may_not_be_is_refused_at_loadfailed on the unfixed tree (DID NOT RAISE) and passes with the fix.test_a_term_may_read_another_sum_its_file_adds_toholds that a read of another sum without a loop back still loads.Gates.
pixicannot be installed in this environment, so I ran the tools from a venv directly:ruff formatandruff check src tests tools(0.16.1): clean.pytest -q -n auto: 2545 passed, 52 skipped.pyrefly check(1.2.0): the same 14 errors as onmain. All are missingpydantic/yamlstubs in the venv, and none are inlowering.py.lefthook,docs-buildorcompile-tex.Not done. #763 moves this check into
lowering._termunderadds_to:. This PR fixes it onmainfirst. #763 takes it when it mergesmainin. No docs page states the self-read rule, so no page changes.🤖 Generated with Claude Code
https://claude.ai/code/session_01AzXL2w5xdUm8FsYMNWf1KW
Generated by Claude Code