github.com/solo-io/cue@v0.4.7/cue/testdata/comprehensions/issue837.txtar (about) 1 -- in.cue -- 2 #DeploymentManifest: #Manifest & {ref: kind: "deployment"} 3 4 #Manifest: { 5 ref: #ManifestRef 6 description: #KumoriKinds[ref.kind] 7 } 8 9 #ManifestRef: kind: #KindsNames 10 11 #KindsNames: "service" | "deployment" 12 13 #KumoriKinds: deployment: #Deployment 14 #KumoriKinds: [string]: {...} 15 16 #DoDeploy: { 17 _params: manifest: #DeploymentManifest 18 deployment: { 19 description: { 20 let dep = _params.manifest.description 21 service: (#Configure & { 22 _params: hsize: dep.hsize 23 }).service 24 } 25 } 26 } 27 28 #Configure: { 29 $p=_params: { 30 hsize: [string]: #RoleSize 31 } 32 service: { 33 description: { 34 let configed = (#RelabelService & { 35 _params: { 36 hsize: $p.hsize 37 } 38 }).out 39 40 role: configed.role 41 } 42 } 43 } 44 45 #RelabelService: { 46 $p=_params: { 47 hsize: #RoleSize 48 } 49 50 out: { 51 labstr: $p.label 52 } 53 } 54 55 #RoleSize: { 56 $_instances: >=0 | *1 57 } 58 59 #Deployment: { 60 service: #ServiceManifest 61 hsize: [service.description.#roles]: #RoleSize 62 } 63 64 #ServiceManifest: #Manifest & {ref: kind: "service"} 65 -- out/eval -- 66 Errors: 67 _params.hsize.$_instances: conflicting values 1 and {$_instances:(>=0|*1)} (mismatched types int and struct): 68 ./in.cue:29:20 69 ./in.cue:35:13 70 ./in.cue:54:12 71 ./in.cue:55:22 72 _params.hsize.$_instances: conflicting values >=0 and {$_instances:(>=0|*1)} (mismatched types number and struct): 73 ./in.cue:29:20 74 ./in.cue:35:13 75 ./in.cue:54:12 76 ./in.cue:55:15 77 #DoDeploy._params.manifest.description.service.description: undefined field: service: 78 ./in.cue:5:28 79 _params.hsize.$_instances: 2 errors in empty disjunction:: 80 ./in.cue:33:20 81 #RelabelService.out.labstr: undefined field: label: 82 ./in.cue:50:14 83 84 Result: 85 (_|_){ 86 // [eval] 87 #DeploymentManifest: (#struct){ 88 ref: (#struct){ 89 kind: (string){ "deployment" } 90 } 91 description: (#struct){ 92 service: (#struct){ 93 ref: (#struct){ 94 kind: (string){ "service" } 95 } 96 description: (_|_){ 97 // [incomplete] #DeploymentManifest.description.service.description: undefined field: service: 98 // ./in.cue:5:28 99 } 100 } 101 hsize: (#struct){ 102 } 103 } 104 } 105 #Manifest: (#struct){ 106 ref: (#struct){ 107 kind: (string){ |((string){ "service" }, (string){ "deployment" }) } 108 } 109 description: (_|_){ 110 // [incomplete] #Manifest.description: unresolved disjunction "service" | "deployment" (type string): 111 // ./in.cue:5:15 112 } 113 } 114 #ManifestRef: (#struct){ 115 kind: (string){ |((string){ "service" }, (string){ "deployment" }) } 116 } 117 #KindsNames: (string){ |((string){ "service" }, (string){ "deployment" }) } 118 #KumoriKinds: (#struct){ 119 deployment: (#struct){ 120 service: (#struct){ 121 ref: (#struct){ 122 kind: (string){ "service" } 123 } 124 description: (_|_){ 125 // [incomplete] #KumoriKinds.deployment.service.description: undefined field: service: 126 // ./in.cue:5:28 127 } 128 } 129 hsize: (#struct){ 130 } 131 } 132 } 133 #DoDeploy: (_|_){ 134 // [eval] 135 _params: (#struct){ 136 manifest: (#struct){ 137 ref: (#struct){ 138 kind: (string){ "deployment" } 139 } 140 description: (#struct){ 141 service: (#struct){ 142 ref: (#struct){ 143 kind: (string){ "service" } 144 } 145 description: (_|_){ 146 // [eval] #DoDeploy._params.manifest.description.service.description: undefined field: service: 147 // ./in.cue:5:28 148 } 149 } 150 hsize: (#struct){ 151 } 152 } 153 } 154 } 155 deployment: (_|_){ 156 // [eval] 157 description: (_|_){ 158 // [eval] 159 service: (_|_){ 160 // [eval] #DoDeploy._params.manifest.description.service.description: undefined field: service: 161 // ./in.cue:5:28 162 } 163 } 164 } 165 } 166 #Configure: (_|_){ 167 // [eval] 168 _params: (#struct){ 169 hsize: (#struct){ 170 } 171 } 172 service: (_|_){ 173 // [eval] 174 description: (_|_){ 175 // [eval] 176 role: (_|_){ 177 // [eval] _params.hsize.$_instances: conflicting values 1 and {$_instances:(>=0|*1)} (mismatched types int and struct): 178 // ./in.cue:29:20 179 // ./in.cue:35:13 180 // ./in.cue:54:12 181 // ./in.cue:55:22 182 // _params.hsize.$_instances: conflicting values >=0 and {$_instances:(>=0|*1)} (mismatched types number and struct): 183 // ./in.cue:29:20 184 // ./in.cue:35:13 185 // ./in.cue:54:12 186 // ./in.cue:55:15 187 // _params.hsize.$_instances: 2 errors in empty disjunction:: 188 // ./in.cue:33:20 189 } 190 } 191 } 192 } 193 #RelabelService: (_|_){ 194 // [eval] 195 _params: (#struct){ 196 hsize: (#struct){ 197 $_instances: (number){ |(*(int){ 1 }, (number){ >=0 }) } 198 } 199 } 200 out: (_|_){ 201 // [eval] 202 labstr: (_|_){ 203 // [eval] #RelabelService.out.labstr: undefined field: label: 204 // ./in.cue:50:14 205 } 206 } 207 } 208 #RoleSize: (#struct){ 209 $_instances: (number){ |(*(int){ 1 }, (number){ >=0 }) } 210 } 211 #Deployment: (#struct){ 212 service: (#struct){ 213 ref: (#struct){ 214 kind: (string){ "service" } 215 } 216 description: (_|_){ 217 // [incomplete] #Deployment.service.description: undefined field: service: 218 // ./in.cue:5:28 219 } 220 } 221 hsize: (#struct){ 222 } 223 } 224 #ServiceManifest: (#struct){ 225 ref: (#struct){ 226 kind: (string){ "service" } 227 } 228 description: (_|_){ 229 // [incomplete] #ServiceManifest.description: undefined field: service: 230 // ./in.cue:5:28 231 } 232 } 233 } 234 -- out/compile -- 235 --- in.cue 236 { 237 #DeploymentManifest: (〈0;#Manifest〉 & { 238 ref: { 239 kind: "deployment" 240 } 241 }) 242 #Manifest: { 243 ref: 〈1;#ManifestRef〉 244 description: 〈1;#KumoriKinds〉[〈0;ref〉.kind] 245 } 246 #ManifestRef: { 247 kind: 〈1;#KindsNames〉 248 } 249 #KindsNames: ("service"|"deployment") 250 #KumoriKinds: { 251 deployment: 〈1;#Deployment〉 252 } 253 #KumoriKinds: { 254 [string]: { 255 ... 256 } 257 } 258 #DoDeploy: { 259 _params: { 260 manifest: 〈2;#DeploymentManifest〉 261 } 262 deployment: { 263 description: { 264 service: (〈3;#Configure〉 & { 265 _params: { 266 hsize: 〈2;let dep〉.hsize 267 } 268 }).service 269 } 270 } 271 } 272 #Configure: { 273 _params: { 274 hsize: { 275 [string]: 〈3;#RoleSize〉 276 } 277 } 278 service: { 279 description: { 280 role: 〈0;let configed〉.role 281 } 282 } 283 } 284 #RelabelService: { 285 _params: { 286 hsize: 〈2;#RoleSize〉 287 } 288 out: { 289 labstr: 〈1;_params〉.label 290 } 291 } 292 #RoleSize: { 293 $_instances: (>=0|*1) 294 } 295 #Deployment: { 296 service: 〈1;#ServiceManifest〉 297 hsize: { 298 [〈1;service〉.description.#roles]: 〈2;#RoleSize〉 299 } 300 } 301 #ServiceManifest: (〈0;#Manifest〉 & { 302 ref: { 303 kind: "service" 304 } 305 }) 306 }