Skip to content

engine: no simulation test covers out-of-range VECTOR ELM MAP offsets #579

Closed

Description

@bpowers

VECTOR ELM MAP returns NaN when an offset lands outside the source array, and picks between reading the whole source and a slice of it, based on the source's total length.
No end-to-end simulation test checks either decision.
If that length were computed wrong, the Vensim-output tests (vector.dat, vector_simple.dat) would still pass, because neither model has an out-of-range offset or a sliced source.

Example

y[DimA] = VECTOR ELM MAP(d[DimA, B1], offset[DimA]), where the offset for A3 walks past the end of d's storage, should give NaN for y[A3].
Forcing the length to a wrong value in the compiler left every simulation test green.

Why it matters

A wrong length gives a wrong number or a missed NaN, silently.
No real model is known to hit it; this is a test gap, not an observed bug.

Fix

Add one small model-level test per branch (whole-array source and sliced source) with an out-of-range offset, asserting NaN.
Whether real Vensim returns :NA: for an out-of-range offset is unverified.

Pointers

  • src/simlin-engine/src/vm_vector_elm_map.rs
  • src/simlin-engine/src/array_tests.rs (the out_of_bounds_element_returns_nan_* tests)

Activity

  1. added
    engine
    on Jun 8, 2026
  2. added
    hygiene
    on Oct 12, 2026
  3. changed the title [-]engine: VECTOR ELM MAP full_source_len has no genuine-Vensim numeric end-to-end test gate (defense-in-depth coverage gap)[/-] [+]engine: no simulation test covers out-of-range VECTOR ELM MAP offsets[/+] on Oct 12, 2026
  4. bpowers commented on Oct 12, 2026

    @bpowers
    OwnerAuthor

    Closing: already fixed on main.

    Both branches have a model-level out-of-range test asserting NaN in src/simlin-engine/src/array_tests.rs: whole-array source in out_of_bounds_element_returns_nan_vm (:3524) and sliced source d[DimA,B1] in strict_slice_source_oob_returns_nan_vm (:3676, added by PR #736).

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

    enginehygiene

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions