github.com/solo-io/cue@v0.4.7/cue/testdata/builtins/closed.txtar (about) 1 -- in.cue -- 2 a: close({ 3 a: b: int 4 }) 5 6 b: a & { x: int } // err 7 c: a & { a: c: int } // okay (non-recursive close) 8 9 inDisjunctions: { 10 x: [string]: #Def 11 #Def: [string]: { 12 a: b: true 13 let X = a 14 close({uint: a: b: X.b}) | close({string: a: b: true}) 15 } 16 x: socket: string: {} 17 x: syslog: x.socket 18 x: syslog: xxx: {} 19 } 20 21 issue642: { 22 test: close({ 23 a: _ 24 b: x: _ 25 } & { 26 [string]: y: _ 27 }) 28 29 test: a: x: _ 30 test: b: x: _ 31 } 32 33 // Issue 642 34 withSubfields: { 35 test: close({ 36 a: _ 37 b: x: _ 38 [string]: y: _ 39 }) 40 41 test: a: x: _ 42 test: b: x: _ 43 } 44 45 -- out/eval -- 46 Errors: 47 b: field not allowed: x: 48 ./in.cue:1:10 49 ./in.cue:5:4 50 ./in.cue:5:10 51 52 Result: 53 (_|_){ 54 // [eval] 55 a: (#struct){ 56 a: (struct){ 57 b: (int){ int } 58 } 59 } 60 b: (_|_){ 61 // [eval] 62 a: (struct){ 63 b: (int){ int } 64 } 65 x: (_|_){ 66 // [eval] b: field not allowed: x: 67 // ./in.cue:1:10 68 // ./in.cue:5:4 69 // ./in.cue:5:10 70 } 71 } 72 c: (#struct){ 73 a: (struct){ 74 b: (int){ int } 75 c: (int){ int } 76 } 77 } 78 inDisjunctions: (struct){ 79 x: (struct){ 80 socket: (#struct){ 81 string: (#struct){ |((#struct){ 82 a: (#struct){ 83 b: (bool){ true } 84 } 85 uint: (#struct){ 86 a: (#struct){ 87 b: (bool){ true } 88 } 89 } 90 }, (#struct){ 91 a: (#struct){ 92 b: (bool){ true } 93 } 94 string: (#struct){ 95 a: (#struct){ 96 b: (bool){ true } 97 } 98 } 99 }) } 100 } 101 syslog: (#struct){ 102 string: (#struct){ |((#struct){ 103 a: (#struct){ 104 b: (bool){ true } 105 } 106 uint: (#struct){ 107 a: (#struct){ 108 b: (bool){ true } 109 } 110 } 111 }, (#struct){ 112 a: (#struct){ 113 b: (bool){ true } 114 } 115 string: (#struct){ 116 a: (#struct){ 117 b: (bool){ true } 118 } 119 } 120 }) } 121 xxx: (#struct){ |((#struct){ 122 a: (#struct){ 123 b: (bool){ true } 124 } 125 uint: (#struct){ 126 a: (#struct){ 127 b: (bool){ true } 128 } 129 } 130 }, (#struct){ 131 a: (#struct){ 132 b: (bool){ true } 133 } 134 string: (#struct){ 135 a: (#struct){ 136 b: (bool){ true } 137 } 138 } 139 }) } 140 } 141 } 142 #Def: (#struct){ 143 } 144 } 145 issue642: (struct){ 146 test: (#struct){ 147 a: (struct){ 148 y: (_){ _ } 149 x: (_){ _ } 150 } 151 b: (struct){ 152 x: (_){ _ } 153 y: (_){ _ } 154 } 155 } 156 } 157 withSubfields: (struct){ 158 test: (#struct){ 159 a: (struct){ 160 y: (_){ _ } 161 x: (_){ _ } 162 } 163 b: (struct){ 164 x: (_){ _ } 165 y: (_){ _ } 166 } 167 } 168 } 169 } 170 -- out/compile -- 171 --- in.cue 172 { 173 a: close({ 174 a: { 175 b: int 176 } 177 }) 178 b: (〈0;a〉 & { 179 x: int 180 }) 181 c: (〈0;a〉 & { 182 a: { 183 c: int 184 } 185 }) 186 inDisjunctions: { 187 x: { 188 [string]: 〈1;#Def〉 189 } 190 #Def: { 191 [string]: { 192 a: { 193 b: true 194 } 195 (close({ 196 uint: { 197 a: { 198 b: 〈3;let X〉.b 199 } 200 } 201 })|close({ 202 string: { 203 a: { 204 b: true 205 } 206 } 207 })) 208 } 209 } 210 x: { 211 socket: { 212 string: {} 213 } 214 } 215 x: { 216 syslog: 〈1;x〉.socket 217 } 218 x: { 219 syslog: { 220 xxx: {} 221 } 222 } 223 } 224 issue642: { 225 test: close(({ 226 a: _ 227 b: { 228 x: _ 229 } 230 } & { 231 [string]: { 232 y: _ 233 } 234 })) 235 test: { 236 a: { 237 x: _ 238 } 239 } 240 test: { 241 b: { 242 x: _ 243 } 244 } 245 } 246 withSubfields: { 247 test: close({ 248 a: _ 249 b: { 250 x: _ 251 } 252 [string]: { 253 y: _ 254 } 255 }) 256 test: { 257 a: { 258 x: _ 259 } 260 } 261 test: { 262 b: { 263 x: _ 264 } 265 } 266 } 267 }