Skip to content

Do not evaluate root prose as expressions#78

Merged
DavidSagan merged 1 commit into
mainfrom
skip-root-prose-expressions
Jul 24, 2026
Merged

Do not evaluate root prose as expressions#78
DavidSagan merged 1 commit into
mainfrom
skip-root-prose-expressions

Conversation

@DavidSagan

Copy link
Copy Markdown
Member

authors, notes and reminders are free-form prose (fundamentals.md, s:palsroot), but substitute_values evaluated their entries like any other scalar. Evaluation fails, and looks_like_expression then reads any / or parenthesis in the text as arithmetic, so a translated file's provenance note

PALS:
  notes:
    - "Translated from Bmad lattice file: /nfs/acc/user/dcs16/.../lat.bmad"

was reported as could not evaluate expression: .... The report was arbitrary — a note with no punctuation stayed silent — and authors and reminders were exposed the same way ("D. Sagan (Cornell)" would trip it via the parens).

The three keys are added to non_expr_keys(). That alone does not reach them: a notes entry is an unkeyed list item, so the key-based skip never sees it. The bare-sequence branch of substitute_values now takes its decision from the key of the list the entry sits in, instead of hard-coding the one case (line) it knew about.

Consequence worth noting: inherit was already in non_expr_keys(), so a list-valued inherit: [a, b] now skips its entries too. Same latent bug, now consistent with the scalar form.

Regression test in test_expressions.cpp covers all three keys with both shapes that trip looks_like_expression — a path and parentheses. It fails against the unmodified expander with 3 == 0 (one problem per prose line) and passes with the fix. Full suite: 1168 assertions in 225 cases.

🤖 Generated with Claude Code

`authors`, `notes` and `reminders` are free-form prose (fundamentals.md,
s:palsroot), but substitute_values evaluated their entries like any other
scalar. Evaluation fails, and looks_like_expression then reads any `/` or
parenthesis in the text as arithmetic, so a translated file's provenance
note -- "Translated from /nfs/acc/user/.../lat.bmad" -- was reported as a
broken expression.

Add the three keys to non_expr_keys(). The keyed skip alone does not reach
them, since a `notes` entry is an unkeyed list item, so the bare-sequence
branch now takes its decision from the key of the list it sits in rather
than hard-coding `line`. That also covers a list-valued `inherit`, which
was already in non_expr_keys() but only honoured in its scalar form.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@DavidSagan
DavidSagan merged commit 85235af into main Jul 24, 2026
3 checks passed
@DavidSagan
DavidSagan deleted the skip-root-prose-expressions branch July 24, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant