Skip to content

engine: ACTIVE INITIAL with a SMOOTH or PREVIOUS on both sides fails #1034

Open

Description

@bpowers

A variable whose ACTIVE INITIAL and its regular equation both call a function that creates a helper (SMTH1, DELAY1, PREVIOUS, INIT, ...) fails to compile.
The error names a compiler-internal variable the user never wrote.

Example

x = ACTIVE INITIAL(PREVIOUS(a * 2, 0), PREVIOUS(b * 3, 0))

fails with

duplicate_variable -- two different synthesized helpers both claim the name '$⁚x⁚0⁚arg0'

The same happens for the apply-to-all form, and for an XMILE per-element equation that carries its own <initial_eqn>.

Why it matters

No model in the test corpus does this: the five ACTIVE INITIAL uses in test/ all have plain expressions in both arguments.
The rejection is safe: the earlier behavior silently ran the initial-phase helper during the simulation, a wrong number.
The problem is the message, which a modeler cannot act on.

Fix

Recommended: keep rejecting, but say so in the modeler's terms, e.g. "x: ACTIVE INITIAL whose equation and initial value both use SMTH1/PREVIOUS/... is not supported".

Alternative, to make it compile: the dt pass and the initial pass each number their helpers from 0, so both produce $⁚x⁚0⁚arg0.
Add a phase marker to the helper's name for the initial pass.
The name is built in one function, so downstream stages follow; the cost is that the initials schedule must run the initial-pass helper and the flow schedule must not, plus the matching test changes.
When done, change an_active_initial_that_collides_a_helper_name_is_refused to assert all three forms compile and each phase reads its own expression.

Pointers

  • src/simlin-engine/src/capture.rs: synthetic_ident (helper names), insert_implicit_var (the rejection and its message)
  • src/simlin-engine/src/variable.rs: parse_var (merges the dt and initial passes)
  • src/simlin-engine/src/db/fragment_determinism_tests.rs: an_active_initial_that_collides_a_helper_name_is_refused

Activity

  1. added
    bug
    engine
    on Sep 2, 2026
  2. changed the title [-]engine: ACTIVE INITIAL whose dt and initial equations both hoist a helper is refused as duplicate_variable (no phase discriminator in synthetic_ident)[/-] [+]engine: ACTIVE INITIAL with a SMOOTH or PREVIOUS on both sides fails[/+] on Oct 12, 2026
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