Skip to content

Expression type checking for mxcli check (microflows + nanoflows) #580

@ako

Description

@ako

Tracking issue for the v0.13.0 milestone. Design: docs/11-proposals/PROPOSAL_expression_type_checking.md.

Problem

mxcli check is a syntactic validator today. It catches grammar errors but not type mismatches that produce silent wrong results or CE errors in Studio Pro. Examples that pass mxcli check today:

-- Silent wrong result: + is numeric add, not string concat
declare $Label string = 'Order #' + $Order/OrderNumber;  -- OrderNumber is Integer

-- Silent empty results: enum compared as string literal
if $Order/Status = 'Open' then ...   -- Status is enum; should be Module.OrderStatus.Open

-- Runtime CE0109: parseInteger expects String
declare $N integer = parseInteger($Count);  -- $Count is Integer

Studio Pro catches these at design time; mxcli should too.

Scope

Microflows and nanoflows in this milestone. Pages and security rules use different expression contexts and are out of scope.

Two tiers:

Tier Requires project? Examples
Scope-local No Variable type tracking, + overload mismatch, function argument count
Catalog-backed Yes (--references) Attribute type vs. comparison value, enum-in-expression vs. XPath, microflow return type

Acceptance criteria

  • mxcli check reports type errors on all three examples above with actionable messages and line/column positions.
  • The three example bugs each become a unit test in the type checker package, locking in detection.
  • LSP surfaces scope-local errors as real-time diagnostics in VS Code (same channel as MDL-WIDGET01).
  • mxcli check --references extends to catalog-backed checks; passes silently without --references to avoid blocking offline use.
  • New mdl-examples/bug-tests/ fixtures cover each catch.
  • Documentation: skill file at .claude/skills/type-check.md plus docs-site page with the error code list (e.g. MDL-TYPE001..N).

Non-goals

  • Type checking page expressions (different context, deferred to v0.14+).
  • Type checking security XPath constraints (catalog-driven; partially covered already by entity-access validation).
  • Inferring types Studio Pro itself cannot infer.

Out of milestone but related

Phases

The proposal proposes implementation in tiers:

  1. Scope-local type tracker — walks microflow/nanoflow body, builds a variable→type map per scope, validates expression and activity argument types against it.
  2. Function/operator type table — enumerate Mendix built-in functions with signature (arg types) -> return type; check call sites against the table.
  3. Catalog-backed attribute/enum checks — when --references is on, resolve $obj/Attr to a declared type from the catalog and validate downstream usage.
  4. LSP wiring — surface scope-local diagnostics in real time without project access.
  5. Catalog-backed LSP — opt-in when the catalog is loaded.

Each phase is independently shippable.

References

  • Proposal: docs/11-proposals/PROPOSAL_expression_type_checking.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions