fix: support @Module.Const syntax in expressions#179
fix: support @Module.Const syntax in expressions#179engalar wants to merge 3 commits intomendixlabs:mainfrom
Conversation
ako
left a comment
There was a problem hiding this comment.
Surgical, minimal fix that restores DESCRIBE roundtrip for microflows referencing constants.
What's good
- Full-stack change in 5 files: 1 grammar line, 1 AST type, 1 visitor case, 2 formatter cases
- Backward compatible —
getConstantValue('Mod.Const')still works - Reuses existing
ATtoken (no lexer changes)
Concerns
Potential parser ambiguity with @annotation. The grammar already uses AT IDENTIFIER for annotations like @Documentation. Adding AT qualifiedName to atomicExpression should be fine since contexts don't overlap (annotations are statement-level, expressions are body-level), but a test confirming this would close the gap.
No regression tests. The PR's main value is DESCRIBE roundtrip but there's no test verifying parse → describe → re-parse for a microflow with @Module.Const. A doctype-test entry would prevent regression.
Two expressionToString functions in different files both got the new case. This kind of duplication is a maintenance hazard but outside the scope of this PR.
QualifiedNameExpr change in cmd_diff_mdl.go is unrelated to the constant reference fix — looks like a separate bug being piggybacked. Should be its own commit ideally.
LGTM.
ef1cdde to
2410f33
Compare
AI Code ReviewCritical IssuesNone found. Moderate Issues
Minor Issues
What Looks Good
RecommendationRequest changes to verify full-stack consistency:
Once these are verified, the PR is ready for approval as it correctly implements the feature following all architectural guidelines. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
Parser now accepts @QualifiedName as a constant reference in any expression context (DECLARE, SET, CHANGE, etc.), matching the output of DESCRIBE MICROFLOW. This restores the round-trip guarantee: DESCRIBE output can be fed back into CREATE without modification.
…oString The Executor.expressionToString method in cmd_diff_mdl.go was missing cases for ConstantRefExpr and QualifiedNameExpr, causing mxcli diff to output Go struct formatting instead of valid MDL syntax.
Adds regression coverage for the parse→check roundtrip of constant references using @Module.Const syntax in microflow DECLARE statements and compound expressions. Addresses review feedback on PR mendixlabs#179.
2410f33 to
4f92da2
Compare
AI Code ReviewWhat Looks Good
RecommendationApprove - The PR properly implements the requested Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
Fixes #178
Summary
@QualifiedNameas a validatomicExpressionin the MDL grammar for constant referencesConstantRefExprAST node type for clean representation@ Module.Constparse tree toConstantRefExprexpressionToString()outputs@Module.Constfor BSON serializationgetConstantValue('Module.Const')still worksRound-trip restored
Test plan
mxcli checkaccepts@Module.Constsyntaxmxcli checkstill acceptsgetConstantValue('Module.Const')syntax