You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
engine: systems stock names can collide with names the translator invents #438
The systems translator invents variable names from the user's stock names (a_max, a_to_b, a_outflows, a_drained_1, ...).
If a user's stock already has one of those names, the model fails to compile with a "two variables of one name" error that names a variable the user never wrote.
It should instead say which line of the systems file collides with which generated name.
Example
A(10, 20) > B @ 1
A_max(5)
A has a maximum but is not a flow destination, so the translator adds an auxiliary a_max to hold that maximum.
The user's stock A_max is also a_max, and compilation fails with a duplicate-variable error on a_max.
Other collisions of the same kind: a stock named A_to_B next to a flow A > B, or the repeat-numbering of parallel flows (A > B twice generates a_to_b_2, which collides with a flow A > B_2; see #399).
Why it matters
Since the engine began rejecting duplicate variable names (#885), this no longer produces wrong numbers; it produces a confusing error.
Seen only in constructed cases: a modeler would rarely name a stock A_max or A_to_B.
Fix
After building the variable list, check every generated name against the user's stock names and return a translation error naming the stock and the generated name it collides with.
Alternative: give generated names a prefix users cannot type (as the engine's own helpers use $⁚); this removes the collision entirely, but the systems writer recognizes generated variables by these exact names and would have to change too.
Pointers
src/simlin-engine/src/systems/translate.rs: translate (every format! that builds an ident, the _max block near the end)
src/simlin-engine/src/systems/writer.rs: find_stock_max and the _drained_ / _remaining reverse rewrites, which depend on these names
changed the title [-]Synthesized _max aux can shadow user-authored variables[/-][+]engine: systems stock names can collide with names the translator invents[/+]on Oct 12, 2026
Activity
[-]Synthesized _max aux can shadow user-authored variables[/-][+]engine: systems stock names can collide with names the translator invents[/+]