Skip to content

Make MDL syntax errors point at the fix, not just the location - #29

Merged
ako merged 1 commit into
mainfrom
fix/parse-error-messages
Jul 25, 2026
Merged

Make MDL syntax errors point at the fix, not just the location#29
ako merged 1 commit into
mainfrom
fix/parse-error-messages

Conversation

@ako

@ako ako commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Answers "do MDL syntax errors give enough info to know the correct syntax?" — before this, partly: a curated set of ~4 mistakes got a great message, but the rest fell through to raw ANTLR (precise location, but noisy expecting {30 tokens} dumps, cryptic "no viable alternative", and misattributed "missing THEN at $Cell"). This widens the existing enhanceErrorMessage layer.

Changes

  1. Collapse the token-set dumps. ANTLR's statement-start failure lists ~30 internal token names:

    extraneous input '(' expecting {<EOF>, DOC_COMMENT, CREATE, ALTER, DROP, … IDENTIFIER}
    

    → now:

    extraneous input '(' expecting the start of a statement (create, alter, drop, show, describe, …)
    

    Other oversized sets are truncated; small useful sets (expecting ':') are left intact.

  2. Precise not $xnot($x) hint (findings Multi-version pluggable widgets: resolve CE0463 generically, add widget describe, docs #3). Keyed off the offending source line (the parse error surfaces downstream as "missing THEN at $x"), scoped to not $var so it never false-fires on not(...), is not null, etc.:

    Mendix requires parentheses around a negated expression …
      if not($Cell/IsInvalid) then …   (correct)
      if not $Cell/IsInvalid then …    (wrong — causes parse error)
    
  3. A [see: mxcli syntax <topic>] pointer on any error that didn't match a specific hint — always a route to the correct form.

Notes

  • The error listener now keeps the source lines so hints can inspect the offending line.
  • Existing curated hints (quoted-grant, enum =, misplaced extends, unescaped apostrophe, reserved keyword) are unchanged.
  • Tests: token-dump collapse, small-set-preserved, bare-not hint (unit + end-to-end via Build); the apostrophe/grant/enum tests were updated to assert on their specific hint text rather than "message changed" (since the generic pointer now always appends).
  • make check-mdl green; visitor + executor suites pass.

🤖 Generated with Claude Code


Generated by Claude Code

Parse errors were precise on line:col but often didn't convey the correct
syntax — the sudoku findings repeatedly hit this (#3 "missing THEN at $Cell",
plus 30-token `expecting {…}` dumps and cryptic "no viable alternative"). mxcli
already had an enhanceErrorMessage layer for ~4 curated cases; this widens it:

- Collapse ANTLR's oversized `expecting {…}` token-set dumps. The all-statement-
  keywords set (~30 internal token names) becomes "expecting the start of a
  statement (create, alter, drop, show, describe, …)"; any other oversized set is
  truncated. Small, useful sets (e.g. `expecting ':'`) are left untouched.
- Add a precise `not $x` → `not($x)` hint, keyed off the offending source line
  (the parse error surfaces downstream, so the line is the reliable signal).
  Scoped to `not $var` to stay false-positive-free (won't fire on `not(...)`,
  `is not null`, etc.).
- Append a one-line `[see: mxcli syntax <topic>]` pointer on any error that
  didn't match a specific hint, so the correct form is one command away.

The error listener now keeps the source lines so hints can inspect the offending
line. Tests: token-dump collapse, small-set preserved, bare-not hint (unit +
end-to-end via Build), plus the existing apostrophe/grant/enum assertions updated
to match on their specific hint text rather than "message changed".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JXnEgoc2NQP1Y2TWMCMXC4
@ako
ako merged commit 87de214 into main Jul 25, 2026
3 checks passed
ako pushed a commit that referenced this pull request Jul 28, 2026
Verification round found that the #27 narrowing wrongly treated `Paragraph`
render mode as block-level. On Mendix 11.12.1 + Atlas a Paragraph-mode
dynamictext renders as an inline `<span>`, so two adjacent Paragraph widgets fuse
(`PARA-ONEPARA-TWO`) exactly like Text-mode ones — and the advisory was silently
missing them.

`inlineDynamicText` now treats ONLY H1–H6 as block-level (`headingRenderModeRe`);
Text/unset and Paragraph are both inline. The advisory message is corrected to
recommend a heading RenderMode (not Paragraph, which does not fix the problem).

Tests updated: Paragraph+Paragraph and Paragraph+Text now flagged, heading pairs
still excluded. Repro ledger-27 extended to show all three cases. Symptom table
notes the lesson: verify Mendix render behavior empirically — a name like
"Paragraph" does not imply `display: block`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JXnEgoc2NQP1Y2TWMCMXC4
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.

2 participants