Skip to content

fix(parser): print the trace once in @def trace mode (#344) - #347

Merged
ocots merged 1 commit into
chore/deps-examodels-0.12from
fix/def-trace-double-print-344
Aug 31, 2026
Merged

fix(parser): print the trace once in @def trace mode (#344)#347
ocots merged 1 commit into
chore/deps-examodels-0.12from
fix/def-trace-double-print-344

Conversation

@ocots

@ocots ocots commented Aug 31, 2026

Copy link
Copy Markdown
Member

Closes #344.

Sibling of #345 — both branch from chore/deps-examodels-0.12 and target it, so they can be reviewed and merged in any order (no overlap: this touches def_fun, #345 touches p_constraint!).

Problem

@def name … end true (trace mode) printed the parsed model twice, identical apart from gensym numbers.

When the :exa backend is active (the default), def_fun parses the definition once with backend=:fun and then, because is_active_backend(:exa), calls def_exa(e; log=log) to embed the ExaModels builder — a second parse! pass. Both passes run their log && println(...) traces.

Change

The :exa sub-parse inside def_fun now runs with log=false; the :fun pass already emitted the trace.

if is_active_backend(:exa)
    build_exa = def_exa(e; log=false)   # was: log=log
    ...

Public API

No change — only the duplicated trace output goes away.

Tests

test/test_onepass_fun.jl ("log" testset): captures stdout around CTParser.def_fun(ex; log=true) with :exa active 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

`@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>
@github-actions
github-actions Bot requested a review from jbcaillau August 31, 2026 14:06
@ocots
ocots merged commit 5628d78 into chore/deps-examodels-0.12 Aug 31, 2026
3 checks passed
@ocots
ocots deleted the fix/def-trace-double-print-344 branch August 31, 2026 18:10
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.

2 participants