|
| 1 | +-- ============================================================================ |
| 2 | +-- Bug #322: Multiline source expression whitespace lost on roundtrip |
| 3 | +-- ============================================================================ |
| 4 | +-- |
| 5 | +-- Symptom (before fix): |
| 6 | +-- The visitor rebuilt expression strings from parsed expression nodes, |
| 7 | +-- so original line breaks and whitespace inside DECLARE initial values |
| 8 | +-- and LOG template parameters were normalized away. A multiline |
| 9 | +-- `declare $X string = ...` statement that authors had carefully |
| 10 | +-- formatted across several lines came back as a single very long line |
| 11 | +-- after describe → exec → describe. Inter-parameter blank lines in |
| 12 | +-- `LOG ... WITH (...)` were similarly collapsed, making real-world |
| 13 | +-- microflows non-fixpoint and producing noisy `mxcli diff-local` output. |
| 14 | +-- |
| 15 | +-- After fix: |
| 16 | +-- Added a `SourceExpr` AST node that wraps an expression with its |
| 17 | +-- original source text. The visitor uses `buildSourceExpression` for |
| 18 | +-- source-sensitive declare/log/while expressions, and the executor |
| 19 | +-- serializes `SourceExpr` through to MDL output so the original |
| 20 | +-- whitespace and line breaks survive every roundtrip. |
| 21 | +-- |
| 22 | +-- Usage: |
| 23 | +-- mxcli exec mdl-examples/bug-tests/322-multiline-source-expression-whitespace.mdl -p app.mpr |
| 24 | +-- mxcli -p app.mpr -c "describe microflow BugTest322.MF_MultilineDeclare" |
| 25 | +-- mxcli -p app.mpr -c "describe microflow BugTest322.MF_MultilineLogTemplate" |
| 26 | +-- The describe outputs must keep the multiline shape and must be |
| 27 | +-- fixpoints under describe → exec → describe. |
| 28 | +-- ============================================================================ |
| 29 | + |
| 30 | +create module BugTest322; |
| 31 | + |
| 32 | +-- DECLARE initial value spread across several lines with leading `+`. The |
| 33 | +-- describer must preserve the line breaks rather than collapse them onto |
| 34 | +-- one line. |
| 35 | +create microflow BugTest322.MF_MultilineDeclare ( |
| 36 | + $Page: integer, |
| 37 | + $Token: string |
| 38 | +) |
| 39 | +returns string as $Endpoint |
| 40 | +begin |
| 41 | + declare $Endpoint string = '/api/v1' |
| 42 | ++ '/items?page=' + toString($Page) |
| 43 | ++ '&token=' + $Token; |
| 44 | + |
| 45 | + return $Endpoint; |
| 46 | +end; |
| 47 | +/ |
| 48 | + |
| 49 | +-- LOG template parameters separated by a blank line. The newline-only |
| 50 | +-- whitespace between `{1} = toString($Count)` and the next parameter must |
| 51 | +-- survive the roundtrip. |
| 52 | +create microflow BugTest322.MF_MultilineLogTemplate ( |
| 53 | + $Count: integer, |
| 54 | + $Endpoint: string |
| 55 | +) |
| 56 | +begin |
| 57 | + log info node 'BugTest322' 'Processed {1} items for {2}' with ({1} = toString($Count) |
| 58 | + |
| 59 | +, {2} = $Endpoint); |
| 60 | +end; |
| 61 | +/ |
0 commit comments