Skip to content

engine: permuted element maps were read by position, giving wrong values #756

Closed

Description

@bpowers

An apply-to-all reference across dimensions linked by an explicit element map (simlin:mapping / simlin:elem) read elements by position, ignoring the map.
Results were silently wrong.

Example

Region{a,b}, State{s1,s2}, with element map s1 -> b, s2 -> a.
x[a] = 10, x[b] = 20, target[State] = x[State] * 1.

Expected: target[s1] = 20, target[s2] = 10.
Reported: target[s1] = 10, target[s2] = 20.
The bare spelling target[State] = x * 1 behaved the same.

Current state

On main the map is followed.
src/simlin-engine/src/mapped_reference_semantics_tests.rs runs this case through the VM for each reference spelling (x[State], x[Region], bare x, a stock's flow), with the map declared on either dimension: a permuted map reads [30, 10, 20] from source [10, 20, 30], and a many-to-one map (#753) compiles and reads through the map.
Landed in PR #1010.

Pointers

Activity

  1. added
    bug
    engine
    on Jun 10, 2026
  2. changed the title [-]engine: executed A2A lowering ignores explicit element maps and resolves positionally (silent wrong results for permutation maps)[/-] [+]engine: permuted element maps were read by position, giving wrong values[/+] on Oct 12, 2026
  3. bpowers commented on Oct 12, 2026

    @bpowers
    OwnerAuthor

    Closing: already fixed on main.

    PR #1010 (0140175): mapped_reference_semantics_tests.rs expected requires the Permuted row to read [30, 10, 20] from source [10, 20, 30], and assert_cell also asserts the result is NOT the positional answer; every_cell_of_the_matrix (line 643) runs it through the VM for x[State], x[Region], bare x and a stock flow, in both declaration directions. The rule lives in DimensionsContext::resolve_mapped_read / read_through_mapping (src/simlin-engine/src/dimensions.rs:858, :927).

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

    bugengine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions