github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/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  _params.hsize.$_instances: 2 errors in empty disjunction::
    78      ./in.cue:33:20
    79  #RelabelService.out.labstr: undefined field: label:
    80      ./in.cue:50:14
    81  
    82  Result:
    83  (_|_){
    84    // [eval]
    85    #DeploymentManifest: (#struct){
    86      ref: (#struct){
    87        kind: (string){ "deployment" }
    88      }
    89      description: (#struct){
    90        service: (#struct){
    91          ref: (#struct){
    92            kind: (string){ "service" }
    93          }
    94          description: (_|_){
    95            // [incomplete] #DeploymentManifest.description.service.description: undefined field: service:
    96            //     ./in.cue:5:28
    97          }
    98        }
    99        hsize: (#struct){
   100        }
   101      }
   102    }
   103    #Manifest: (#struct){
   104      ref: (#struct){
   105        kind: (string){ |((string){ "service" }, (string){ "deployment" }) }
   106      }
   107      description: (_|_){
   108        // [incomplete] #Manifest.description: unresolved disjunction "service" | "deployment" (type string):
   109        //     ./in.cue:5:15
   110      }
   111    }
   112    #ManifestRef: (#struct){
   113      kind: (string){ |((string){ "service" }, (string){ "deployment" }) }
   114    }
   115    #KindsNames: (string){ |((string){ "service" }, (string){ "deployment" }) }
   116    #KumoriKinds: (#struct){
   117      deployment: (#struct){
   118        service: (#struct){
   119          ref: (#struct){
   120            kind: (string){ "service" }
   121          }
   122          description: (_|_){
   123            // [incomplete] #KumoriKinds.deployment.service.description: undefined field: service:
   124            //     ./in.cue:5:28
   125          }
   126        }
   127        hsize: (#struct){
   128        }
   129      }
   130    }
   131    #DoDeploy: (_|_){
   132      // [eval]
   133      _params: (#struct){
   134        manifest: (#struct){
   135          ref: (#struct){
   136            kind: (string){ "deployment" }
   137          }
   138          description: (#struct){
   139            service: (#struct){
   140              ref: (#struct){
   141                kind: (string){ "service" }
   142              }
   143              description: (_|_){
   144                // [incomplete] #DoDeploy._params.manifest.description.service.description: undefined field: service:
   145                //     ./in.cue:5:28
   146              }
   147            }
   148            hsize: (#struct){
   149            }
   150          }
   151        }
   152      }
   153      deployment: (_|_){
   154        // [eval]
   155        description: (_|_){
   156          // [eval]
   157          service: (_|_){
   158            // [eval] _params.hsize.$_instances: conflicting values 1 and {$_instances:(>=0|*1)} (mismatched types int and struct):
   159            //     ./in.cue:29:20
   160            //     ./in.cue:35:13
   161            //     ./in.cue:54:12
   162            //     ./in.cue:55:22
   163            // _params.hsize.$_instances: conflicting values >=0 and {$_instances:(>=0|*1)} (mismatched types number and struct):
   164            //     ./in.cue:29:20
   165            //     ./in.cue:35:13
   166            //     ./in.cue:54:12
   167            //     ./in.cue:55:15
   168            // _params.hsize.$_instances: 2 errors in empty disjunction::
   169            //     ./in.cue:33:20
   170          }
   171        }
   172      }
   173    }
   174    #Configure: (_|_){
   175      // [eval]
   176      _params: (#struct){
   177        hsize: (#struct){
   178        }
   179      }
   180      service: (_|_){
   181        // [eval]
   182        description: (_|_){
   183          // [eval]
   184          role: (_|_){
   185            // [eval] _params.hsize.$_instances: conflicting values 1 and {$_instances:(>=0|*1)} (mismatched types int and struct):
   186            //     ./in.cue:29:20
   187            //     ./in.cue:35:13
   188            //     ./in.cue:54:12
   189            //     ./in.cue:55:22
   190            // _params.hsize.$_instances: conflicting values >=0 and {$_instances:(>=0|*1)} (mismatched types number and struct):
   191            //     ./in.cue:29:20
   192            //     ./in.cue:35:13
   193            //     ./in.cue:54:12
   194            //     ./in.cue:55:15
   195            // _params.hsize.$_instances: 2 errors in empty disjunction::
   196            //     ./in.cue:33:20
   197          }
   198        }
   199      }
   200    }
   201    #RelabelService: (_|_){
   202      // [eval]
   203      _params: (#struct){
   204        hsize: (#struct){
   205          $_instances: (number){ |(*(int){ 1 }, (number){ >=0 }) }
   206        }
   207      }
   208      out: (_|_){
   209        // [eval]
   210        labstr: (_|_){
   211          // [eval] #RelabelService.out.labstr: undefined field: label:
   212          //     ./in.cue:50:14
   213        }
   214      }
   215    }
   216    #RoleSize: (#struct){
   217      $_instances: (number){ |(*(int){ 1 }, (number){ >=0 }) }
   218    }
   219    #Deployment: (#struct){
   220      service: (#struct){
   221        ref: (#struct){
   222          kind: (string){ "service" }
   223        }
   224        description: (_|_){
   225          // [incomplete] #Deployment.service.description: undefined field: service:
   226          //     ./in.cue:5:28
   227        }
   228      }
   229      hsize: (#struct){
   230      }
   231    }
   232    #ServiceManifest: (#struct){
   233      ref: (#struct){
   234        kind: (string){ "service" }
   235      }
   236      description: (_|_){
   237        // [incomplete] #ServiceManifest.description: undefined field: service:
   238        //     ./in.cue:5:28
   239      }
   240    }
   241  }
   242  -- out/compile --
   243  --- in.cue
   244  {
   245    #DeploymentManifest: (〈0;#Manifest〉 & {
   246      ref: {
   247        kind: "deployment"
   248      }
   249    })
   250    #Manifest: {
   251      ref: 〈1;#ManifestRef〉
   252      description: 〈1;#KumoriKinds〉[〈0;ref〉.kind]
   253    }
   254    #ManifestRef: {
   255      kind: 〈1;#KindsNames〉
   256    }
   257    #KindsNames: ("service"|"deployment")
   258    #KumoriKinds: {
   259      deployment: 〈1;#Deployment〉
   260    }
   261    #KumoriKinds: {
   262      [string]: {
   263        ...
   264      }
   265    }
   266    #DoDeploy: {
   267      _params: {
   268        manifest: 〈2;#DeploymentManifest〉
   269      }
   270      deployment: {
   271        description: {
   272          service: (〈3;#Configure〉 & {
   273            _params: {
   274              hsize: 〈2;let dep〉.hsize
   275            }
   276          }).service
   277        }
   278      }
   279    }
   280    #Configure: {
   281      _params: {
   282        hsize: {
   283          [string]: 〈3;#RoleSize〉
   284        }
   285      }
   286      service: {
   287        description: {
   288          role: 〈0;let configed〉.role
   289        }
   290      }
   291    }
   292    #RelabelService: {
   293      _params: {
   294        hsize: 〈2;#RoleSize〉
   295      }
   296      out: {
   297        labstr: 〈1;_params〉.label
   298      }
   299    }
   300    #RoleSize: {
   301      $_instances: (>=0|*1)
   302    }
   303    #Deployment: {
   304      service: 〈1;#ServiceManifest〉
   305      hsize: {
   306        [〈1;service〉.description.#roles]: 〈2;#RoleSize〉
   307      }
   308    }
   309    #ServiceManifest: (〈0;#Manifest〉 & {
   310      ref: {
   311        kind: "service"
   312      }
   313    })
   314  }