github.com/solo-io/cue@v0.4.7/cue/testdata/cycle/023_reentrance.txtar (about) 1 # DO NOT EDIT; generated by go run testdata/gen.go 2 # 3 #name: reentrance 4 #evalFull 5 -- in.cue -- 6 // This indirection is needed to avoid binding references to fib 7 // within fib to the instantiated version. 8 fibRec: {nn: int, out: (fib & {n: nn}).out} 9 fib: { 10 n: int 11 12 if n >= 2 { 13 out: (fibRec & {nn: n - 2}).out + (fibRec & {nn: n - 1}).out 14 } 15 if n < 2 { 16 out: n 17 } 18 } 19 fib2: (fib & {n: 2}).out 20 fib7: (fib & {n: 7}).out 21 fib12: (fib & {n: 12}).out 22 -- out/def -- 23 // This indirection is needed to avoid binding references to fib 24 // within fib to the instantiated version. 25 fibRec: { 26 nn: int 27 out: (fib & { 28 n: nn 29 }).out 30 } 31 fib: { 32 n: int 33 if n >= 2 { 34 out: (fibRec & { 35 nn: n - 2 36 }).out + (fibRec & { 37 nn: n - 1 38 }).out 39 } 40 if n < 2 { 41 out: n 42 } 43 } 44 fib2: 1 45 fib7: 13 46 fib12: 144 47 -- out/legacy-debug -- 48 <0>{fibRec: <1>{nn: int, out: (<2>.fib & <3>{n: <4>.nn}).out}, fib: <5>{n: int if (<6>.n >= 2) yield <7>{out: ((<2>.fibRec & <8>{nn: (<6>.n - 2)}).out + (<2>.fibRec & <9>{nn: (<6>.n - 1)}).out)}, if (<6>.n < 2) yield <10>{out: <6>.n}}, fib2: 1, fib7: 13, fib12: 144} 49 -- out/compile -- 50 --- in.cue 51 { 52 fibRec: { 53 nn: int 54 out: (〈1;fib〉 & { 55 n: 〈1;nn〉 56 }).out 57 } 58 fib: { 59 n: int 60 if (〈0;n〉 >= 2) { 61 out: ((〈2;fibRec〉 & { 62 nn: (〈2;n〉 - 2) 63 }).out + (〈2;fibRec〉 & { 64 nn: (〈2;n〉 - 1) 65 }).out) 66 } 67 if (〈0;n〉 < 2) { 68 out: 〈1;n〉 69 } 70 } 71 fib2: (〈0;fib〉 & { 72 n: 2 73 }).out 74 fib7: (〈0;fib〉 & { 75 n: 7 76 }).out 77 fib12: (〈0;fib〉 & { 78 n: 12 79 }).out 80 } 81 -- out/eval -- 82 Errors: 83 structural cycle: 84 ./in.cue:8:9 85 86 Result: 87 (_|_){ 88 // [structural cycle] 89 fibRec: (struct){ 90 nn: (int){ int } 91 out: (_|_){ 92 // [incomplete] non-concrete value int in operand to >=: 93 // ./in.cue:7:5 94 // ./in.cue:3:32 95 // ./in.cue:5:2 96 // non-concrete value int in operand to <: 97 // ./in.cue:10:5 98 // ./in.cue:3:32 99 // ./in.cue:5:2 100 } 101 } 102 fib: (_|_){ 103 // [incomplete] fib: non-concrete value int in operand to >=: 104 // ./in.cue:7:5 105 // ./in.cue:5:2 106 // fib: non-concrete value int in operand to <: 107 // ./in.cue:10:5 108 // ./in.cue:5:2 109 n: (int){ int } 110 } 111 fib2: (int){ 1 } 112 fib7: (_|_){ 113 // [structural cycle] structural cycle: 114 // ./in.cue:8:9 115 } 116 fib12: (_|_){ 117 // [structural cycle] structural cycle: 118 // ./in.cue:8:9 119 } 120 }