Skip to content

Fix cross-case method contamination when running multiple cases in the same REPL#118

Open
slifer50 wants to merge 1 commit into
sm/newmasterfrom
yt/repl_case_dispatch
Open

Fix cross-case method contamination when running multiple cases in the same REPL#118
slifer50 wants to merge 1 commit into
sm/newmasterfrom
yt/repl_case_dispatch

Conversation

@slifer50

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: When running case A then case B in the same Julia session, methods defined in A's user_source.jl/user_primitives.jl/user_bc.jl persist in the global method table and silently override B's methods.
  • src/run.jl: Before reloading case files, explicitly delete all methods of user_flux!, user_source!, user_bc_dirichlet!, user_primitives!, user_uout!. These functions have no definitions in src/ — every method comes from a case file — so a full delete-then-reload is safe.
  • 108 case files across all problem directories (AdvDiff, Burgers, CompEuler, Elliptic, Helmholtz, ShallowWater, acoustics): replace runtime ET == TOTAL() / ET == PERT() checks with proper ::TOTAL / ::PERT type dispatch, and remove ::TInt / ::Int64 type annotations on npoin. This makes methods unambiguous when reloaded and ensures correct dispatch without relying on stale method ordering.

Test plan

  • Run case A (e.g. theta) in a REPL session, then immediately run case B (e.g. 3d) without restarting Julia — verify B uses its own user_source! and not A's
  • Verify all existing single-case runs still produce correct output
  • Confirm no method ambiguity warnings on reload

🤖 Generated with Claude Code

…e same REPL

When a user runs case A then case B in the same Julia session, methods defined
in A's user_source.jl/user_primitives.jl persist in the global method table
and get called instead of B's methods, causing incorrect results silently.

Two-part fix:

1. src/run.jl: Before reloading case files, explicitly delete all methods of
   user_flux!, user_source!, user_bc_dirichlet!, user_primitives!, user_uout!.
   These functions have no definitions in src/ — every method comes from a case
   file — so a full delete-then-reload is safe and sufficient.

2. 108 case files (user_source.jl, user_primitives.jl, user_bc.jl across all
   problem directories): Replace runtime ET == TOTAL() / ET == PERT() checks
   with proper ::TOTAL / ::PERT type dispatch, and remove ::TInt / ::Int64 type
   annotations on the npoin argument. This makes methods unambiguous when
   reloaded into a clean method table, and ensures Julia dispatches correctly
   without relying on stale method ordering.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@slifer50 slifer50 requested a review from smarras79 June 30, 2026 15:09
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.

1 participant