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