Do not evaluate root prose as expressions#78
Merged
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
authors,notesandremindersare free-form prose (fundamentals.md, s:palsroot), butsubstitute_valuesevaluated their entries like any other scalar. Evaluation fails, andlooks_like_expressionthen reads any/or parenthesis in the text as arithmetic, so a translated file's provenance notewas reported as
could not evaluate expression: .... The report was arbitrary — a note with no punctuation stayed silent — andauthorsandreminderswere 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: anotesentry is an unkeyed list item, so the key-based skip never sees it. The bare-sequence branch ofsubstitute_valuesnow 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:
inheritwas already innon_expr_keys(), so a list-valuedinherit: [a, b]now skips its entries too. Same latent bug, now consistent with the scalar form.Regression test in
test_expressions.cppcovers all three keys with both shapes that triplooks_like_expression— a path and parentheses. It fails against the unmodified expander with3 == 0(one problem per prose line) and passes with the fix. Full suite: 1168 assertions in 225 cases.🤖 Generated with Claude Code