Skip to content

fix(microflows): preserve ELSIF arms by lowering to nested IfStmt (#745)#746

Draft
mlehane1 wants to merge 1 commit into
mendixlabs:mainfrom
mlehane1:fix/745-elsif-arms-dropped
Draft

fix(microflows): preserve ELSIF arms by lowering to nested IfStmt (#745)#746
mlehane1 wants to merge 1 commit into
mendixlabs:mainfrom
mlehane1:fix/745-elsif-arms-dropped

Conversation

@mlehane1

@mlehane1 mlehane1 commented Jul 9, 2026

Copy link
Copy Markdown

Fixes #745.

What

buildIfStatement (mdl/visitor/visitor_microflow_statements.go) read only exprs[0]/bodies[0] and the trailing ELSE body, so every middle (ELSIF expression THEN microflowBody)* pair from the grammar was silently dropped from the written model — check and exec reported success and mx check was clean, making the data loss invisible.

Mendix has no native elsif construct, so this lowers each ELSIF arm into a nested IfStmt in the ELSE branch of the arm before it (built innermost-first) — the canonical nested-exclusive-split shape Studio Pro users build by hand. Plain IF/ELSE builds exactly as before (regression-guarded).

Validation

  • Unit tests (new mdl/visitor/visitor_microflow_elsif_test.go): elsif chain preserved with conditions/bodies at each level; elsif-without-else (innermost arm has no ELSE); plain if/else unchanged (no gratuitous nesting). Written failing-first against the old visitor.
  • Bug-test script: mdl-examples/bug-tests/745-elsif-arms-dropped.mdl — exec against a fresh mxcli new 11.11.0 app, then DESCRIBE MICROFLOW BugTestElsif.MF_Grade shows all four arms (one/two/three/other) as a nested if/else chain with sensible auto-layout positions. mx check = 0 errors on the resulting app (Windows, mx 11.11.0).
  • Suites: go test ./mdl/... ./sdk/... green; go vet ./mdl/... clean (grammar regenerated with ANTLR 4.13.1).
  • Agentic testing: found, root-caused, fixed, and end-to-end verified via Claude Code driving mxcli headless (exec → describe round-trip → mx check) against real .mpr apps.
  • Symptom row added to .claude/skills/fix-issue.md per the bug-fix checklist.

Opened as a draft pending maintainer sign-off on #745 per CONTRIBUTING.md.

🤖 Generated with Claude Code

buildIfStatement read only exprs[0]/bodies[0] and the trailing ELSE
body, so every middle (ELSIF expression THEN microflowBody)* pair from
the grammar was silently dropped from the written model — check and
exec reported success and mx check was clean, making the data loss
invisible.

Mendix has no native elsif construct, so lower each ELSIF arm into a
nested IfStmt in the ELSE branch of the arm before it (built innermost
first) — the canonical nested-exclusive-split shape. Plain IF/ELSE
builds exactly as before.

Verified end-to-end: exec of the bug-test script against a fresh
11.11.0 app, DESCRIBE round-trips all arms as nested if/else, mx check
0 errors. go test ./mdl/... ./sdk/... green.
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.

IF/ELSIF/ELSE silently drops every ELSIF arm on write (both engines)

1 participant