Repository navigation
Description
TestProject's array_* builders accept a subscript naming a dimension the fixture never declares, so a test can build a model that does not compile and still pass.
build_datamodel should refuse such a fixture with a clear panic.
Example
TestProject::new("x")
.indexed_dimension("D", 2)
.array_aux("pp[D,2]", "1") // no dimension named `2`This builds without complaint; pp then fails to compile with BadDimensionName.
Why it matters
It has already produced a test that proved nothing.
allocate_target_per_element_partials_decline (src/simlin-engine/src/db/ltm_rank_decline_tests.rs) built exactly this fixture and asserted that LTM declines to score ALLOCATE's per-element links.
It passed because the model never compiled, not because the decline logic ran.
#1057 fixed that fixture and added an assert_model_compiles guard to that one file, but nothing stops the next typo'd or forgotten dimension elsewhere; the builders are called about 2,600 times across about 90 files in simlin-engine and libsimlin.
Fix
Check in build_datamodel, the one place every helper (run_vm, error_diagnostics, flow_exprs, ...) goes through, rather than in each array_* method, since builder chains declare dimensions and variables in any order:
- every dimension named by an
ApplyToAllorArrayedequation must be declared; - compare with
canonicalize, since fixtures rely on case-insensitive names (arrayed_helper_resolves_capitalized_dimensiondeclaresRegionand usesregion); - panic naming the variable, the missing dimension and the declared ones;
- skip projects built with
from_datamodel.
About 20 lines, plus a cargo test --workspace sweep for fixtures that currently rely on the gap.
No builder-based test deliberately wants an undeclared dimension; the one test that does (test_unknown_element_subscript_skips_unresolved_dimension in db/diagnostic_tests.rs) builds its datamodel::Project directly, and any others the sweep finds should move to that shape rather than get an opt-out flag.
Pointers
src/simlin-engine/src/test_common.rs:build_datamodel,parse_array_declaration
Activity
[-]test: TestProject array_* builders accept a subscript over an undeclared dimension, so a fixture can pass on a model that never compiles[/-][+]test: TestProject accepts arrays over undeclared dimensions[/+]