Skip to content

Multi-output submodel with wrong number of LHS outputs leaks a cryptic MethodError #310

Description

@docxology

Summary

Multi-output submodel calls ((a, b) ~ sub(x = x)) must have the number of LHS outputs
equal to the number of missing (un-named) interfaces. When they differ, the path falls
through to MethodError: no method matching make_node!(...) with no indication of the real
problem. The single-output path already validates this and raises a clear error
(src/graph_engine.jl:1858-1873); the multi-output path (1875-1886) does not.

Root cause

prepare_interfaces_multi (src/graph_engine.jl:1881-1886) builds a NamedTuple from
missing interfaces + LHS, without checking length(missing) == length(lhs). A mismatch
leaks a MethodError.

Repro / existing test

test/multi_and_zero_output_tests.jl:76 currently pins the confusing behaviour:

@test_throws "no method matching make_node!" create_model(main_mismatch()) do model, ctx ... end

Suggested fix

Add an explicit check in prepare_interfaces (Tuple-LHS) with a clear message:

if length(missing) != n_lhs
    error("Submodel '$fform' expects $(length(missing)) output interface(s) but $(n_lhs) were provided on the LHS.")
end

Update the test to assert the readable message.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions