fix(parser): print the trace once in @def trace mode (#344) - #347
Merged
Conversation
`@def name … end true` printed the parsed model twice whenever the `:exa` backend was active: `def_fun` re-parses the definition to build the ExaModels artifact and that second pass inherited the `log` flag, re-emitting the whole trace. The `:exa` sub-parse now runs with `log=false`; the `:fun` pass already produced the trace. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Aug 31, 2026
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.
Closes #344.
Sibling of #345 — both branch from
chore/deps-examodels-0.12and target it, so they can be reviewed and merged in any order (no overlap: this touchesdef_fun, #345 touchesp_constraint!).Problem
@def name … end true(trace mode) printed the parsed model twice, identical apart from gensym numbers.When the
:exabackend is active (the default),def_funparses the definition once withbackend=:funand then, becauseis_active_backend(:exa), callsdef_exa(e; log=log)to embed the ExaModels builder — a secondparse!pass. Both passes run theirlog && println(...)traces.Change
The
:exasub-parse insidedef_funnow runs withlog=false; the:funpass already emitted the trace.Public API
No change — only the duplicated trace output goes away.
Tests
test/test_onepass_fun.jl("log"testset): capturesstdoutaroundCTParser.def_fun(ex; log=true)with:exaactive and asserts each trace marker appears exactly once.Full suite green locally: 2594 pass, 9 broken (pre-existing), 0 fail/error.
🤖 Generated with Claude Code