Skip to content

State-machine query operators in ModelingToolkitTearing throw UndefVarError for wrap #170

Open

Description

@baggepinnen

Goal

I am adding Modelica-style state machines to SynchToolkit (JuliaComputing/SynchToolkit.jl#252). The state machines are declared with the operators in lib/ModelingToolkitTearing/src/clock_inference/state_machines.jl. Transition conditions and equations refer to the state of a machine through the query operators activeState, ticksInState, timeInState and entry.

What fails

Every method of these four operators throws on ModelingToolkitTearing 1.20.7, and the code on main is the same:

using ModelingToolkit
using ModelingToolkit: t_nounits as t
import ModelingToolkit.MTKTearing as MTKT

@named s1 = System(Equation[], t, [], [])
MTKT.activeState(s1)
ERROR: UndefVarError: `wrap` not defined in `ModelingToolkitTearing`
Suggestion: check for spelling errors or missing imports.
Hint: a global variable of this name also exists in Symbolics.
Stacktrace:
 [1] activeState(x::System)
   @ ModelingToolkitTearing ~/.julia/packages/ModelingToolkitTearing/gRDNi/src/clock_inference/state_machines.jl:77

The zero-argument methods (ticksInState(), timeInState(), entry()) fail in the same way. transition and initial_state work.

The methods are generated by the loop at state_machines.jl:71-83 and call wrap(term($s, x)). wrap is not exported by Symbolics 7. The file does not appear to be covered by tests.

Workaround

SynchToolkit defines its own activeState, ticksInState, timeInState and entry, which construct the terms with Symbolics.wrap(SymbolicUtils.term(f, s; type, shape)).


Host: demeter2 · Session: https://claude.ai/code/session_01S12pk8C416QqoxphWRcPz8 · Working directory: ~/.julia/dev/SynchToolkit/.claude/worktrees/ancient-waddling-spindle

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