Skip to content

engine: MDL writer emits zero-arg builtin calls like PI() that the MDL parser rejects (Vensim has no PI builtin) #850

Closed

Description

@bpowers

Problem

The MDL writer prints zero-argument builtin calls such as XMILE pi() as PI(). This output is doubly wrong:

  1. simlin's own MDL parser rejects it on re-parse: symbol call requires at least one argument.
  2. Vensim has no PI builtin at all, so the exported file is invalid Vensim MDL regardless.

In src/simlin-engine/src/mdl/writer.rs, mdl_bare_keyword (~line 181) only handles time, dt/time_step, starttime/initial_time, and endtime/stoptime/final_time; pi (and any other zero-arg builtin) falls through to the generic uppercase-function path and prints as NAME().

Impact

Part of the 29/240 re-parse failures found by a corpus sweep (parse -> project_to_mdl -> re-parse over all test/**/*.mdl under 200KB). Affected fixtures include:

  • test/metasd/industrial-dynamics/IDch15/IDch15d.mdl
  • test/metasd/thyroid/thyroid-2008-d.mdl

Component

src/simlin-engine/src/mdl/writer.rs (MdlPrintVisitor::walk, mdl_bare_keyword)

Possible approach

Emit a numeric literal for pi() (e.g. 3.14159265358979), matching what Vensim models actually contain. More generally, audit all zero-arg XMILE builtins reachable through the writer and give each an explicit MDL rendering (bare keyword, literal, or a documented reject) instead of the generic NAME() fallback. The corpus re-parse sweep from #847 would gate this too.

Related: #847 tracks the other (larger) re-parse failure class, wildcard subscripts printed as * instead of Dim!.

Context: identified during an MDL writer round-trip corpus sweep.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions