Skip to content

feat(pages): write a page variable's default as a bare expression - #1086

Merged
ako merged 3 commits into
mainfrom
claude/nice-einstein-a74lz4
Oct 9, 2026
Merged

ako merged 3 commits into
mainfrom
claude/nice-einstein-a74lz4

Conversation

@ako

@ako ako commented Oct 9, 2026

Copy link
Copy Markdown
Owner

What

A page or snippet variable's default is a Mendix expression, but MDL took it in a string whose content was the expression: $show: Boolean = 'true', = 'if (3 < 4) then true else false'. It can now be written bare, like every other expression (R5):

create page M.P (Title: 'P', Layout: Atlas_Core.Atlas_Default,
  Variables: ( $show: Boolean = true, $limit: Integer = 20,
               $big: Boolean = if 3 < 4 then true else false,
               $label: String = 'Price' + ' list', $status: Enumeration(M.Status) = M.Status.Open )) { … };
alter page M.P { add variables $extra: Boolean = not(false) };

This works in create page, create snippet and alter page … add variables, which all share variableDeclaration.

Language version

mdl 1 is frozen (ADR-0011), so = 'true' cannot change meaning in it. The string form therefore keeps its meaning (its content is the expression) under every language version. It becomes the deprecated alias MDL-DEPR086, refused from mdl 2, following the precedent of MDL-DEPR080 for workflow expressions:

  • check and exec warn on it.
  • fmt --upgrade rewrites it to the bare form.

One exception: a default that is itself a Mendix string ($s: String = '''abc''') or is empty has no bare spelling yet, because a bare 'abc' is this very alias. Those keep their current form and are not reported.

Changes

  • Grammar: variableDeclaration takes (STRING_LITERAL /* @alias MDL-DEPR086 */ | expression).
  • Visitor: stores the bare expression's source text. ExitVariableDeclaration records DEPR086 with the rewrite. VariableDefaultReadsBack decides whether a default can be written bare.
  • Describe: prints the bare default whenever it reads back as the same default, and the quoted form otherwise.
  • Registry: DEPR086 added with an example and a canonical example, which the registry tests check. The generated migration table in docs-site/src/language/versions.md is regenerated.
  • Example scripts: the five scripts using the quoted form were converted with fmt --upgrade itself, which changed only their defaults (including an enumeration value).
  • Docs, syntax help, skills, the MDL-WIDGET34 suggestion and the R2 header-map test fixtures now use the bare form. Those fixtures had the quoted form as their canonical case.

Verification

  • Unit tests:
    • every bare form, including a list whose function-argument commas aren't taken for the list's
    • snippet and ALTER
    • DEPR086 recorded only on the alias, under both mdl 0 and mdl 1, and not on '''abc''' or ''
    • the fmt --upgrade rewrite for create and ALTER
    • the describe round trip
  • Control: forcing describe back to always quoting fails the round-trip test (3 cases).
  • End to end on a copy of ako/TestApp (Mendix 11.14.0):
    • The stored DefaultValue is exactly the expression written for every form; '''abc''' stores 'abc'.
    • describe prints them bare, and only the one quoted default warned.
    • mx check is clean, including a column Visible: $a and $big over the variables.
  • Integration test: TestPageVariableInputBinding_RoundTrip passed locally (it ran, not skipped).
  • Gates: make build && make test && make lint && make check-mdl && make check-migration-reference && make check-findings all pass on the branch rebased onto main.

Found while verifying, not changed here: Mendix rejects a default that refers to another page variable ($x: Boolean = not($a) is CE0117 in mx check), and the quoted spelling fails the same way. A check rule for it would be a separate change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P65SqmwwvbWdJVRwhYiMQw


Generated by Claude Code

claude added 3 commits October 9, 2026 21:31
A page or snippet variable's default is a Mendix expression, but MDL took
it in a string whose content was the expression: `$show: Boolean =
'true'`. It is now written bare (R5) — `= true`, `= if (3 < 4) then true
else false`, `= 'Price' + ' list'`, `= Module.Enum.Value` — in create
page, create snippet and `alter page … add variables`.

mdl 1 is frozen, so the string form keeps its meaning under every
language version and is the deprecated alias MDL-DEPR086 (refused from
mdl 2), with the `fmt --upgrade` rewrite. A default that is itself a
string (`'''abc'''`) or empty has no bare spelling yet — the bare `'abc'`
is the alias — and is not reported. describe writes the bare form when it
reads back as the same default.

The example scripts were converted with fmt --upgrade itself; docs,
syntax help, skills and the generated migration table follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P65SqmwwvbWdJVRwhYiMQw
The R2 brace/paren tests used `$show: Boolean = 'true'` as their
canonical form, which MDL-DEPR086 now reports, so each case recorded two
deprecations instead of the one it exercises, and describe's expected
output was the quoted form. The defaults are written bare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P65SqmwwvbWdJVRwhYiMQw
The generic ALTER PAGE syntax help and the grammar comment, both changed
on main since, still showed `$show: Boolean = 'true'` (MDL-DEPR086).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P65SqmwwvbWdJVRwhYiMQw
@ako
ako merged commit b056182 into main Oct 9, 2026
33 checks passed
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