Aggregates broke when SET became optional (upstream CI regression) - #112
Merged
Conversation
Making SET optional put `$X = <expr>` in front of every `VARIABLE EQUALS <function-call>` statement in the grammar. ANTLR picks the lowest-numbered alternative that matches, so `$Sum = sum($List.Price)` stopped reaching aggregateListStatement and fell through to the generic SET conversion, which joined the list and the attribute into one name. mxbuild rejected the result on both engines: [CE0109] "Undefined variable 'ProductList.Price'." [CE0015] "Aggregate function must specify a valid attribute." Move setStatement last so it only claims what no dedicated rule parses, and make the SET conversion agree with the canonical one — it also dropped the per-item expression of `sum($List, $currentObject/Price * 0.21)`, which buildListAggregateAsFunction never appended in the first place. That half was wrong before the bare form ever reached it, so `set $X = sum($List.Price)` was broken too. Proved by reverting both halves: the new tests fail with the reported symptom, and the same script executed against a blank 11.12.1 project reports 8 errors on a control binary and 0 with the fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JXnEgoc2NQP1Y2TWMCMXC4
ako
pushed a commit
that referenced
this pull request
Aug 8, 2026
Brings the branch up to date with main (PR #112) so the PR merges cleanly and CI runs against the current base. No conflicts; the fix-issue.md symptom table merged via the union driver with both sides' rows intact and no duplicates. Full suite green on the merged tree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018hifgRSawfaRWXS44YKtSJ
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.
Fixes the
TestMxCheck_DoctypeScripts/02-microflow-examples.mdlfailure on the upstream sync PR — six errors on both engines, from a regression ine0744b9e("make SET optional"):What broke
Making
SEToptional turnedsetStatementinto$X = <expr>, which overlaps everyVARIABLE EQUALS <function-call>statement in the grammar. It sat at alternative 5 of ~50, and ANTLR's ALL(*) picks the lowest-numbered alternative that matches — so$Sum = sum($List.Price)stopped reachingaggregateListStatementand fell into the generic SET conversion, which joined the list and the attribute into one name and dropped the per-item expression.Two fixes, because there were two defects
setStatementmoved last inmicroflowStatement, so it only claims what no dedicated rule parses. Restores the previous routing for aggregates, list operations andRANGEalike.buildSetAggregate), andbuildListAggregateAsFunctionappends the per-item expression argument it never appended. This half was wrong before the bare form ever reached it —set $X = sum($List.Price)produced the same broken aggregate onmaintoday.Verification
Mendix 11.12.1 locally (CI used 11.12.2).
TestMxCheck_DoctypeScripts— all scripts, both engines, realmx checkgo test ./mdl/... ./cmd/...mdl-examples/**/*.mdl, new vsmainbinarymx checkNote on why this shipped
The original
SET?change was swept with a control binary over every example — but withmxcli check, which parses and validates and never serializes. This defect lives between the AST and the BSON, where onlyexec+mx checkcan see it. Recorded in the symptom table: for a grammar change, the control sweep has to run the integration gate, notcheck.Files
mdl/grammar/domains/MDLMicroflow.g4—setStatementlast, with a comment saying whymdl/visitor/visitor_microflow_statements.go—buildSetAggregatereplacesextractVariableAndAttributemdl/visitor/visitor_microflow_expression.go—buildListAggregateAsFunctionappends the expression argumentmdl/visitor/visitor_microflow_aggregate_test.go— newmdl-examples/bug-tests/aggregate-after-optional-set.mdl— new.claude/skills/fix-issue.md— symptom row🤖 Generated with Claude Code
https://claude.ai/code/session_01JXnEgoc2NQP1Y2TWMCMXC4
Generated by Claude Code