Conversation
…er of LHS outputs A multi-output submodel call must provide exactly as many outputs on the LHS as there are interfaces left unspecified on the RHS. When it did not, the total arity matched no generated `make_node!` method and dispatch failed with a `MethodError` that said nothing about the real problem. Note this happens one layer earlier than #310 assumed: `prepare_interfaces_multi` is never reached, because the dispatch sites pass `static(length(rhs_interfaces) + length(lhs_interface))` and the generated methods only exist for the model's own `StaticInt{num_interfaces}`. Adds a less specific `make_node!` fallback for `Composite` nodes with `Tuple` or `NamedTuple` LHS that reports the mismatch, and updates the test that previously pinned the `MethodError` text. Closes #310. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #324 +/- ##
==========================================
+ Coverage 90.72% 90.73% +0.01%
==========================================
Files 16 16
Lines 2263 2266 +3
==========================================
+ Hits 2053 2056 +3
Misses 210 210 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 #310.
Problem
A multi-output submodel call must provide exactly as many outputs on the LHS as there are
interfaces left unspecified on the RHS. When it doesn't, the user got:
which says nothing about the actual mistake.
Root cause
Not where #310 suggested. The issue proposed adding the check to
prepare_interfaces_multi, butthat function is never reached: the dispatch sites at
src/graph_engine.jl:2055/:2060passstatic(length(rhs_interfaces) + length(lhs_interface)), and the generatedmake_node!methods aredefined only for the model's own
StaticInt{num_interfaces}. A count mismatch means no methodmatches at all, so it fails one layer earlier than the issue assumed.
Change
Added a less specific
make_node!fallback forCompositenodes withTupleorNamedTupleLHS anda generic
StaticInt{N}, which reports the mismatch directly:It is strictly less specific than every generated method (generic in both
fformandN), so it onlyruns when dispatch would otherwise fail — no ambiguity, no shadowing. Message style follows the
existing single-output validation at
:1858-1873(lazy"...",Node '$(fform)', localn = "\n",closing pointer to the documentation).
Tests
test/multi_and_zero_output_tests.jlcurrently pins the bad behaviour with@test_throws "no method matching make_node!". That assertion is replaced with one on the readablemessage, plus two new cases: too few LHS outputs, and the same mismatch in the named-output
(NamedTuple LHS) form.
Verified the existing clear errors for the named form are preserved — a wrong interface name still
matches on arity and reaches
prepare_interfaces, so"Interface ':c' does not exist in ..."and theLHS/RHS conflict error still fire (covered by the existing test items 8 and 9).
Full suite on Julia 1.12: 258/258 test items, all passing.
🤖 Generated with Claude Code