Skip to content

engine: bare builtin name silently shadows a same-named variable #681

Open

Description

@bpowers

Owner decision: keep the current rule with no warning, or warn when a bare builtin name is also a declared variable.

A bare inf, pi, time or dt in an equation means the builtin, even when the model declares a variable with that name; the quoted form "inf" reads the variable.

<aux name="inf"><eqn>42</eqn></aux>
<aux name="bare"><eqn>inf</eqn></aux>        <!-- +infinity, no warning -->
<aux name="quoted"><eqn>"inf"</eqn></aux>    <!-- 42 -->

Everything the engine writes follows the rule (the MDL importer quotes such references, and rename keeps the quotes), and tests pin it (#1073).
The silent case is a person writing the bare name: hand-written XMILE, or the editor, which allows a variable named pi (only clock names are refused).

Fix

Recommended: a warning on a bare zero-argument builtin name that the model also declares as a variable, e.g. "pi here is the builtin; write "pi" to read the variable" (S).
Alternative: close and accept the rule as documented (ast::needs_quoting).

Pointers

  • src/simlin-engine/src/ast/mod.rs: needs_quoting
  • src/simlin-engine/src/ast/expr0.rs: reify_0_arity_builtins
  • src/simlin-engine/src/keyword_ident_tests.rs: a_quoted_builtin_name_reads_the_variable_and_a_bare_one_the_builtin

Activity

  1. added
    engine
    bug
    on Jun 8, 2026
  2. changed the title [-]engine: variable named 'inf' (or other zero-arity builtin name) collides with the Inf builtin and silently reads +infinity[/-] [+]engine: a bare reference to a variable named inf reads the builtin[/+] on Oct 12, 2026
  3. changed the title [-]engine: a bare reference to a variable named inf reads the builtin[/-] [+]engine: bare builtin name silently shadows a same-named variable[/+] 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