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