fix: support @Module.Const syntax in expressions#179
fix: support @Module.Const syntax in expressions#179engalar wants to merge 2 commits intomendixlabs:mainfrom
Conversation
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.
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.
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