Pretty-printer: emit body for opaque define (Refs #931) - #956
Merged
Conversation
4 tasks
`Define.pretty_print` short-circuited to `self.str_header()` whenever
`self.visibility == 'opaque'`, emitting just `opaque define name : type`
without the required `= body`. The parser requires `=` and a body
after every `define`, so the freshly-pretty-printed source for
`opaque define id_one_two : fn OneTwo -> OneTwo = fun b { b }` became
the partial `opaque define id_one_two : (fn OneTwo -> OneTwo)` and the
next top-level `theorem` token failed with
`ParseError: expected "=" after name in "define"`.
That `opaque ⇒ header-only` branch was a leftover from when
`pretty_print` was also used by `.thm` printing to elide opaque bodies.
`GenRecFun`, with the explicit note that `.thm` files now include the
body for opaque declarations and `Import` semantics are unaffected
because opacity is enforced by the checker, not the surface form.
`Define` was simply missed in that pass.
`Define.str_header()` was only used by the dropped opaque branch, and
the now-trivial `pretty_print` (`return str(self)`) just shadowed the
base `Statement.pretty_print`, so both are deleted.
`PARSER_ROUND_TRIP_FILES` gains `ImportTests.pf`, which exercises the
`opaque define id_one_two : fn OneTwo -> OneTwo = fun b { b }`
shape that surfaced this bug.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
jsiek
force-pushed
the
claude/silly-yalow-343b7f
branch
from
June 12, 2026 21:19
e43f3f4 to
eecec0f
Compare
8 tasks
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.
Summary
Define.pretty_printshort-circuited toself.str_header()wheneverself.visibility == 'opaque', emitting only the head (opaque define name : type) and dropping the required= body. The parser requires everydefineto be followed by=and a body, so the freshly-pretty-printed source foropaque define id_one_two : fn OneTwo -> OneTwo = fun b { b }reparsed with aParseError: expected "=" after name in "define"on the next top-level token.pretty_printwas also used by.thmprinting to hide opaque bodies. #935 already removed the same branch fromUnion/RecFun/GenRecFun(Importsemantics are unaffected because opacity is enforced by the checker, not by the surface form).Definewas missed in that pass — fixed now.Define.str_header()was only used by the dropped opaque branch, and the now-trivialpretty_print(return str(self)) just shadowed the baseStatement.pretty_print, so both are deleted.PARSER_ROUND_TRIP_FILESgainstest/should-validate/ImportTests.pf, the existing fixture that exercises theopaque define name : T = fun ...shape (alongsideprivate union,private recursive, and a downstreamexpand id_one_twoproof). After this patch all fourRD/LALR × RD/LALRround-trip combinations pass for that file.Refs #931. Five of the original 8 bug categories plus the recent follow-ups already landed; this is one of the remaining parse-fail items called out in the most recent triage comment.
Test plan
python3.13 test-deduce.py --equiv(parser equivalence + round-trip sweep, including the newImportTests.pfentry)python3.13 test-deduce.py --passable(everytest/should-validate/*.pfstill checks under both parsers)make static(ruff + mypy)Claude session — fallback UUID:
41852f93-8a03-47e4-9c79-35651aa28d9a🤖 Generated with Claude Code