|
| 1 | +-- ============================================================================ |
| 2 | +-- ako/mxcli#1399 (mendixlabs/mxcli#1517) — variables of one alter block, |
| 3 | +-- and a producer moved upstream of where it was |
| 4 | +-- ============================================================================ |
| 5 | +-- |
| 6 | +-- The operations of one `alter microflow` block — and the patch a |
| 7 | +-- `create or modify` splices with, which is one — write ONE flow, but two of |
| 8 | +-- their variable verdicts were still taken against the flow as stored: |
| 9 | +-- |
| 10 | +-- Repro B a fragment was built knowing only the stored flow's variables, |
| 11 | +-- so `set $Late = …` in a replaced loop failed at exec with |
| 12 | +-- "variable 'Late' is not declared" although the insert before it |
| 13 | +-- in the same block declares $Late upstream — while check passed |
| 14 | +-- with a "not predicted" note. |
| 15 | +-- |
| 16 | +-- Used return a producer moved earlier (`$Code = call …` above the |
| 17 | +-- declare it followed) was refused "the fragment declares $Code, |
| 18 | +-- which the microflow already has" by the stored $Code the same |
| 19 | +-- patch drops, and in the other order "$Code is still used by: |
| 20 | +-- log …; return $Code" by readers the moved producer now feeds. |
| 21 | +-- |
| 22 | +-- To reproduce: exec this file against any project. Expected: |
| 23 | +-- Altered microflow BugTest1399.LoopFlow |
| 24 | +-- Modified microflow: BugTest1399.MoveFlow (spliced: 1 inserted, 1 dropped) |
| 25 | +-- Before the fix exec stopped at the alter ("the fragment has errors: variable |
| 26 | +-- 'Late' is not declared") and rolled the whole script back; without the |
| 27 | +-- alter it stopped at the second MoveFlow statement. mx check: 0 errors. |
| 28 | +-- The file can be run again: LoopFlow is dropped and made afresh, and |
| 29 | +-- MoveFlow moves its producer back and forth. |
| 30 | + |
| 31 | +mdl 1; |
| 32 | + |
| 33 | +create module BugTest1399; |
| 34 | + |
| 35 | +create or modify persistent entity BugTest1399.Item ( |
| 36 | + Name: String(100) |
| 37 | +); |
| 38 | + |
| 39 | +create or modify microflow BugTest1399.Helper () returns String |
| 40 | +begin |
| 41 | + return 'x'; |
| 42 | +end; |
| 43 | + |
| 44 | +-- Repro B: the replaced loop sets the variable the insert declares. |
| 45 | +drop microflow if exists BugTest1399.LoopFlow; |
| 46 | + |
| 47 | +create microflow BugTest1399.LoopFlow ($Items: List of BugTest1399.Item) |
| 48 | +begin |
| 49 | + declare $X Integer = 0; |
| 50 | + loop $It in $Items |
| 51 | + begin |
| 52 | + log info node 'BugTest1399' $It/Name; |
| 53 | + end loop; |
| 54 | + log info node 'BugTest1399' 'done'; |
| 55 | +end; |
| 56 | + |
| 57 | +alter microflow BugTest1399.LoopFlow { |
| 58 | + insert after declare $X Integer = 0 begin declare $Late Integer = 0; end; |
| 59 | + replace loop $It in $Items with begin |
| 60 | + loop $It in $Items |
| 61 | + begin |
| 62 | + set $Late = $Late + 1; |
| 63 | + end loop; |
| 64 | + end; |
| 65 | +}; |
| 66 | + |
| 67 | +-- Used return: the producer of the returned $Code moves above the declare. |
| 68 | +create or modify microflow BugTest1399.MoveFlow () returns String |
| 69 | +begin |
| 70 | + declare $N Integer = 1; |
| 71 | + $Code = call microflow BugTest1399.Helper(); |
| 72 | + log info node 'BugTest1399' $Code; |
| 73 | + return $Code; |
| 74 | +end; |
| 75 | + |
| 76 | +create or modify microflow BugTest1399.MoveFlow () returns String |
| 77 | +begin |
| 78 | + $Code = call microflow BugTest1399.Helper(); |
| 79 | + declare $N Integer = 1; |
| 80 | + log info node 'BugTest1399' $Code; |
| 81 | + return $Code; |
| 82 | +end; |
0 commit comments