Skip to content

@caption on a while loop is dropped with no MDL042 — only for-each loops are warned #1187

Description

@tgolembiewski

mxcli version: v0.24.0 (Mendix 11.12.1, MPR v2, macOS)

Summary

@caption on a while loop passes mxcli check, is accepted by exec, and is gone from describe — with no diagnostic. The same @caption on a loop is reported as MDL042 ("@caption on a loop has no effect … use @annotation"). Both statements build the same element: a Microflows$LoopedActivity, which has no Caption property — while only differs by its WhileLoopCondition.

Repro (blank project)

create or modify microflow MyFirstModule.CountMonths ()
returns Integer as $Months
begin
  declare $Months Integer = 0;
  @caption 'Are there months left to count?'
  while $Months < 3
  begin
    set $Months = $Months + 1;
  end while;
  return $Months;
end;
/
  • mxcli check → Check passed!, no warning
  • mxcli exec → Created microflow: MyFirstModule.CountMonths
  • DESCRIBE MICROFLOW MyFirstModule.CountMonths → while $Months < 3 with no caption

The same caption on loop $Item in $Items → ⚠ @caption on a loop has no effect … [MDL042].

Cause

mdl/executor/validate_microflow.go raises MDL042 in the *ast.LoopStmt case only; the *ast.WhileStmt case checks the condition and walks the body but never looks at stmt.Annotations.Caption. addWhileStatement (cmd_microflows_builder_control.go) builds a LoopedActivity like addLoopStatement, so the caption has nowhere to go. @annotation on a while is stored and round-trips through describe.

Suggested fix

Raise MDL042 for a while as well, with the same pointer to @annotation, and say "loop or while loop" in the write-microflows control-flow note. Happy to open the PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions