Skip to content

Refuse set $Obj = … on object variables (mendixlabs/mxcli#1323) - #1011

Merged
ako merged 4 commits into
mainfrom
fix/1323-set-object-variable
Oct 7, 2026
Merged

ako merged 4 commits into
mainfrom
fix/1323-set-object-variable

Conversation

@ako

@ako ako commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes mendixlabs#1323. Reported symptom: set $Cursor = $Next; on two object variables passed check --references and exec, then mx check failed with CE7247 "Variable 'Cursor' does not have a primitive type." Mendix has no action that reassigns an object variable (Change variable takes only primitives; lists use Change list Replace, #949). mxcli now refuses it on every path:

Path Where What it refuses
check (no project) MDL-SET01, validate_microflow_set_object.go (microflows and nanoflows) Objects visible in the script: entity parameters, create, retrieve … first, loop iterators, head, cast
check --references validateFlowBody, now given checkAssociationShapes(ctx, sc) Association-retrieved objects: a Reference followed from its FROM entity. Only these, so the refusal prints once
exec flowBuilder.refuseSetOnObject Any object, also with --no-check

Self-associations, reverse traversals and ReferenceSets stay lists, so set on them is still a valid Replace.

Evidence

  • Tests: mdl/executor/set_object_variable_test.go covers the issue's script verbatim, each producer, a nanoflow, and controls (primitive, list, member path, association retrieve without a project, reverse Reference, ReferenceSet).
  • Revert controls: with the fix reverted, the check and builder tests fail with "check accepted set on object variable $Cursor". With MDL-SET01 stubbed out, every plain-check test fails.
  • Mendix 11.14.0, faulted build vs fixed build:
    • Faulted: the repro passes check and exec, then mx check reports the exact CE7247. Each MDL-SET01 producer and a nanoflow also give CE7247. A parameter is worded "Parameter 'A' cannot be changed.", and the message quotes that.
    • Fixed: check and exec refuse the repro.
    • Still building with 0 errors: the self-association Replace and the recursive sub-microflow workaround.
  • Bug-tests: mdl-examples/bug-tests/1323-set-object-variable.mdl holds the forms that build, and 1323-set-object-variable.fail.mdl holds the refusal. make check-mdl passes.
  • Repo checks: two findings appended, make check-findings passes. make build, make test, make lint (including conformance) and make check-skill-mdl pass after merging main.

Not in scope

A primitive parameter (set $N = 1 on $N: Integer) also fails with CE7247 "Parameter 'N' cannot be changed." and is still not refused. That's queued as a separate task.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PMEw8qsiJuVoaaGJawicfo

claude added 4 commits October 7, 2026 05:49
`set $Cursor = $Next;` with both variables single objects passed
`check --references` and `exec` and was written as a Change variable
action, which mxbuild refuses with CE7247 "Variable 'Cursor' does not
have a primitive type". Mendix has no action that reassigns an object
variable; #949 routed the list case to Change list Replace and
left objects on the primitive-only path.

The builder (exec) and the check validator now refuse it and name the
alternatives. The check validator typed every association retrieve as a
list, so the reported shape (a Reference followed from its FROM entity)
looked like a list to check; under --references it now takes the
association shapes MDL-ASSOCDS01 already builds and types that retrieve
as the object it is. Self-association retrieves stay lists (Mendix types
them so, and `set` on them is a valid Replace).

Measured on 11.14.0: faulted build -> CE7247; fixed build refuses in
check and exec; the self-association and recursive sub-microflow forms
in the bug-test -> 0 errors.

Fixes mendixlabs#1323

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PMEw8qsiJuVoaaGJawicfo
…project

Plain `mxcli check` runs only the MDL0xx rule set, never validateFlowBody,
so the mendixlabs#1323 refusal reached `check --references` and `exec` but not a
check without -p (and check-mdl could not pin it with a .fail.mdl).

MDL-SET01 judges the object producers visible in the text: entity
parameters, create, `retrieve … first`, loop iterators over a known list,
head, cast. Association retrieves need the project and stay with
validateFlowBody, which now reports only those, so --references prints
the refusal once. Microflows and nanoflows.

Measured on 11.14.0 with the faulted build: every producer gives CE7247;
a parameter is worded "Parameter 'A' cannot be changed.", which the
message now quotes.

Part of mendixlabs#1323

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PMEw8qsiJuVoaaGJawicfo
@ako
ako merged commit 47baa6d into main Oct 7, 2026
31 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.

set $Obj = $Other on an object variable passes check and exec; mx check CE7247 "does not have a primitive type" (list case fixed by ako/mxcli#949)

2 participants