cuelang.org/go@v0.13.0/cue/testdata/builtins/matchif.txtar (about) 1 -- in.cue -- 2 regularFields: { 3 [_]: matchIf({x!: >2}, {y!: 5}, {y!: 1}) 4 ok1: {x: 10, y: 5} 5 ok2: {x: 11, y: 5} 6 ok3: {x: 2, y: 1} 7 ok4: {x: 1, y: 1} 8 err1: {x: 10, y: 6} 9 err2: {x: 11, y: 6} 10 err3: {x: 2, y: 5} 11 err4: {x: 1, y: 2} 12 } 13 -- out/eval/stats -- 14 Leaks: 24 15 Freed: 74 16 Reused: 69 17 Allocs: 29 18 Retain: 24 19 20 Unifications: 98 21 Conjuncts: 154 22 Disjuncts: 98 23 -- out/eval -- 24 Errors: 25 regularFields.err1: invalid value {x:10,y:6} (does not satisfy matchIf): conflicting values 5 and 6: 26 ./in.cue:2:7 27 ./in.cue:2:30 28 ./in.cue:7:8 29 ./in.cue:7:19 30 regularFields.err2: invalid value {x:11,y:6} (does not satisfy matchIf): conflicting values 5 and 6: 31 ./in.cue:2:7 32 ./in.cue:2:30 33 ./in.cue:8:8 34 ./in.cue:8:19 35 regularFields.err3: invalid value {x:2,y:5} (does not satisfy matchIf): conflicting values 1 and 5: 36 ./in.cue:2:7 37 ./in.cue:2:39 38 ./in.cue:9:8 39 ./in.cue:9:18 40 regularFields.err4: invalid value {x:1,y:2} (does not satisfy matchIf): conflicting values 1 and 2: 41 ./in.cue:2:7 42 ./in.cue:2:39 43 ./in.cue:10:8 44 ./in.cue:10:18 45 46 Result: 47 (_|_){ 48 // [eval] 49 regularFields: (_|_){ 50 // [eval] 51 ok1: (struct){ 52 x: (int){ 10 } 53 y: (int){ 5 } 54 } 55 ok2: (struct){ 56 x: (int){ 11 } 57 y: (int){ 5 } 58 } 59 ok3: (struct){ 60 x: (int){ 2 } 61 y: (int){ 1 } 62 } 63 ok4: (struct){ 64 x: (int){ 1 } 65 y: (int){ 1 } 66 } 67 err1: (_|_){ 68 // [eval] regularFields.err1: invalid value {x:10,y:6} (does not satisfy matchIf): conflicting values 5 and 6: 69 // ./in.cue:2:7 70 // ./in.cue:2:30 71 // ./in.cue:7:8 72 // ./in.cue:7:19 73 x: (int){ 10 } 74 y: (int){ 6 } 75 } 76 err2: (_|_){ 77 // [eval] regularFields.err2: invalid value {x:11,y:6} (does not satisfy matchIf): conflicting values 5 and 6: 78 // ./in.cue:2:7 79 // ./in.cue:2:30 80 // ./in.cue:8:8 81 // ./in.cue:8:19 82 x: (int){ 11 } 83 y: (int){ 6 } 84 } 85 err3: (_|_){ 86 // [eval] regularFields.err3: invalid value {x:2,y:5} (does not satisfy matchIf): conflicting values 1 and 5: 87 // ./in.cue:2:7 88 // ./in.cue:2:39 89 // ./in.cue:9:8 90 // ./in.cue:9:18 91 x: (int){ 2 } 92 y: (int){ 5 } 93 } 94 err4: (_|_){ 95 // [eval] regularFields.err4: invalid value {x:1,y:2} (does not satisfy matchIf): conflicting values 1 and 2: 96 // ./in.cue:2:7 97 // ./in.cue:2:39 98 // ./in.cue:10:8 99 // ./in.cue:10:18 100 x: (int){ 1 } 101 y: (int){ 2 } 102 } 103 } 104 } 105 -- out/compile -- 106 --- in.cue 107 { 108 regularFields: { 109 [_]: matchIf({ 110 x!: >2 111 }, { 112 y!: 5 113 }, { 114 y!: 1 115 }) 116 ok1: { 117 x: 10 118 y: 5 119 } 120 ok2: { 121 x: 11 122 y: 5 123 } 124 ok3: { 125 x: 2 126 y: 1 127 } 128 ok4: { 129 x: 1 130 y: 1 131 } 132 err1: { 133 x: 10 134 y: 6 135 } 136 err2: { 137 x: 11 138 y: 6 139 } 140 err3: { 141 x: 2 142 y: 5 143 } 144 err4: { 145 x: 1 146 y: 2 147 } 148 } 149 }