-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Description
The underbar_to_space() function in src/simlin-engine/src/mdl/writer.rs emits variable names bare after converting underbars to spaces, without checking whether the resulting identifier contains MDL-special characters ($, /, |, etc.). This produces unparseable MDL output for models with non-standard identifier names.
For example, a variable named $_euro (stored internally as $_euro) would be emitted as:
$ euro=
...
instead of the correct quoted form:
"$ euro"=
...
The Vensim MDL format requires identifiers containing special characters to be enclosed in double-quotes.
Why it matters
This is a correctness gap -- the MDL writer silently produces invalid output for certain inputs rather than failing or handling them properly. While no current test model exercises this path (all 42 roundtrip files use standard alphanumeric names), real-world Vensim models can and do use special characters in variable names.
Components affected
src/simlin-engine/src/mdl/writer.rs--underbar_to_space()and all call sites that emit variable names
Possible approaches
- Add a
needs_quoting()check (similar to the existing one insrc/simlin-engine/src/ast/mod.rs:293) that detects identifiers requiring quoting. - Wrap identifiers that need quoting in double-quotes when emitting them.
- Add a test model (or at minimum a unit test) with special-character identifiers to exercise this path.
Context
Identified during review of PR #324 (MDL writer). No existing roundtrip test model uses special characters in identifiers, so this path is currently untested.