cuelang.org/go@v0.13.0/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  				role: "admin"
    39  			}).out
    40  
    41  			role: configed.role
    42  		}
    43  	}
    44  }
    45  
    46  #RelabelService: {
    47  	$p=_params: {
    48  		hsize: #RoleSize
    49  	}
    50  
    51  	out: {
    52  		labstr: $p.label
    53  	}
    54  }
    55  
    56  #RoleSize: {
    57  	$_instances: >=0 | *1
    58  }
    59  
    60  #Deployment: {
    61  	service: #ServiceManifest
    62  	hsize: [service.description.#roles]: #RoleSize
    63  }
    64  
    65  #ServiceManifest: #Manifest & {ref: kind: "service"}
    66  -- out/evalalpha/stats --
    67  Leaks:  85
    68  Freed:  0
    69  Reused: 0
    70  Allocs: 85
    71  Retain: 0
    72  
    73  Unifications: 61
    74  Conjuncts:    101
    75  Disjuncts:    8
    76  
    77  CloseIDElems: 17
    78  NumCloseIDs: 17
    79  -- out/evalalpha --
    80  Errors:
    81  #RelabelService.out.labstr: undefined field: label:
    82      ./in.cue:51:14
    83  
    84  Result:
    85  (_|_){
    86    // [eval]
    87    #DeploymentManifest: (#struct){
    88      ref: (#struct){
    89        kind: (string){ "deployment" }
    90      }
    91      description: ~(#KumoriKinds.deployment)
    92    }
    93    #Manifest: (#struct){
    94      ref: ~(#ManifestRef)
    95      description: (_|_){
    96        // [incomplete] #Manifest.description: unresolved disjunction "service" | "deployment" (type string):
    97        //     ./in.cue:5:15
    98      }
    99    }
   100    #ManifestRef: (#struct){
   101      kind: (string){ |((string){ "service" }, (string){ "deployment" }) }
   102    }
   103    #KindsNames: (string){ |((string){ "service" }, (string){ "deployment" }) }
   104    #KumoriKinds: (#struct){
   105      deployment: (#struct){
   106        service: ~(#ServiceManifest)
   107        hsize: (_|_){
   108          // [incomplete] #ServiceManifest.description: undefined field: service:
   109          //     ./in.cue:5:28
   110        }
   111      }
   112    }
   113    #DoDeploy: (#struct){
   114      _params: (#struct){
   115        manifest: ~(#DeploymentManifest)
   116      }
   117      deployment: (#struct){
   118        description: (#struct){
   119          let dep#1 = ~(#KumoriKinds.deployment)
   120          service: (#struct){
   121            description: (#struct){
   122              let configed#2 = (_|_){
   123                // [eval]
   124                labstr: (_|_){
   125                  // [eval] #DoDeploy.deployment.description.service.description.configed.labstr: undefined field: label:
   126                  //     ./in.cue:51:14
   127                }
   128              }
   129              role: (_|_){
   130                // [incomplete] #DoDeploy.deployment.description.service.description.role: undefined field: role:
   131                //     ./in.cue:40:19
   132              }
   133            }
   134          }
   135        }
   136      }
   137    }
   138    #Configure: (#struct){
   139      _params: (#struct){
   140        hsize: (#struct){
   141        }
   142      }
   143      service: (#struct){
   144        description: (#struct){
   145          let configed#2 = (_|_){
   146            // [eval]
   147            labstr: (_|_){
   148              // [eval] #Configure.service.description.configed.labstr: undefined field: label:
   149              //     ./in.cue:51:14
   150            }
   151          }
   152          role: (_|_){
   153            // [incomplete] #Configure.service.description.role: undefined field: role:
   154            //     ./in.cue:40:19
   155          }
   156        }
   157      }
   158    }
   159    #RelabelService: (_|_){
   160      // [eval]
   161      _params: (#struct){
   162        hsize: ~(#RoleSize)
   163      }
   164      out: (_|_){
   165        // [eval]
   166        labstr: (_|_){
   167          // [eval] #RelabelService.out.labstr: undefined field: label:
   168          //     ./in.cue:51:14
   169        }
   170      }
   171    }
   172    #RoleSize: (#struct){
   173      $_instances: (number){ |(*(int){ 1 }, (number){ >=0 }) }
   174    }
   175    #Deployment: (#struct){
   176      service: ~(#ServiceManifest)
   177      hsize: (_|_){
   178        // [incomplete] #ServiceManifest.description: undefined field: service:
   179        //     ./in.cue:5:28
   180      }
   181    }
   182    #ServiceManifest: (#struct){
   183      ref: (#struct){
   184        kind: (string){ "service" }
   185      }
   186      description: (_|_){
   187        // [incomplete] #ServiceManifest.description: undefined field: service:
   188        //     ./in.cue:5:28
   189      }
   190    }
   191  }
   192  -- diff/-out/evalalpha<==>+out/eval --
   193  diff old new
   194  --- old
   195  +++ new
   196  @@ -1,8 +1,4 @@
   197   Errors:
   198  -#Configure.service.description.role: undefined field: role:
   199  -    ./in.cue:40:19
   200  -#DoDeploy.deployment.description.service.description.role: undefined field: role:
   201  -    ./in.cue:40:19
   202   #RelabelService.out.labstr: undefined field: label:
   203       ./in.cue:51:14
   204   
   205  @@ -13,24 +9,10 @@
   206       ref: (#struct){
   207         kind: (string){ "deployment" }
   208       }
   209  -    description: (#struct){
   210  -      service: (#struct){
   211  -        ref: (#struct){
   212  -          kind: (string){ "service" }
   213  -        }
   214  -        description: (_|_){
   215  -          // [incomplete] #DeploymentManifest.description.service.description: undefined field: service:
   216  -          //     ./in.cue:5:28
   217  -        }
   218  -      }
   219  -      hsize: (#struct){
   220  -      }
   221  -    }
   222  +    description: ~(#KumoriKinds.deployment)
   223     }
   224     #Manifest: (#struct){
   225  -    ref: (#struct){
   226  -      kind: (string){ |((string){ "service" }, (string){ "deployment" }) }
   227  -    }
   228  +    ref: ~(#ManifestRef)
   229       description: (_|_){
   230         // [incomplete] #Manifest.description: unresolved disjunction "service" | "deployment" (type string):
   231         //     ./in.cue:5:15
   232  @@ -42,62 +24,22 @@
   233     #KindsNames: (string){ |((string){ "service" }, (string){ "deployment" }) }
   234     #KumoriKinds: (#struct){
   235       deployment: (#struct){
   236  -      service: (#struct){
   237  -        ref: (#struct){
   238  -          kind: (string){ "service" }
   239  -        }
   240  -        description: (_|_){
   241  -          // [incomplete] #KumoriKinds.deployment.service.description: undefined field: service:
   242  -          //     ./in.cue:5:28
   243  -        }
   244  -      }
   245  -      hsize: (#struct){
   246  -      }
   247  -    }
   248  -  }
   249  -  #DoDeploy: (_|_){
   250  -    // [eval]
   251  -    _params: (#struct){
   252  -      manifest: (#struct){
   253  -        ref: (#struct){
   254  -          kind: (string){ "deployment" }
   255  -        }
   256  -        description: (#struct){
   257  -          service: (#struct){
   258  -            ref: (#struct){
   259  -              kind: (string){ "service" }
   260  -            }
   261  -            description: (_|_){
   262  -              // [incomplete] #DoDeploy._params.manifest.description.service.description: undefined field: service:
   263  -              //     ./in.cue:5:28
   264  -            }
   265  -          }
   266  -          hsize: (#struct){
   267  -          }
   268  -        }
   269  -      }
   270  -    }
   271  -    deployment: (_|_){
   272  -      // [eval]
   273  -      description: (_|_){
   274  -        // [eval]
   275  -        let dep#1 = (#struct){
   276  -          service: (#struct){
   277  -            ref: (#struct){
   278  -              kind: (string){ "service" }
   279  -            }
   280  -            description: (_|_){
   281  -              // [incomplete] #DoDeploy.deployment.description.dep.service.description: undefined field: service:
   282  -              //     ./in.cue:5:28
   283  -            }
   284  -          }
   285  -          hsize: (#struct){
   286  -          }
   287  -        }
   288  -        service: (_|_){
   289  -          // [eval]
   290  -          description: (_|_){
   291  -            // [eval]
   292  +      service: ~(#ServiceManifest)
   293  +      hsize: (_|_){
   294  +        // [incomplete] #ServiceManifest.description: undefined field: service:
   295  +        //     ./in.cue:5:28
   296  +      }
   297  +    }
   298  +  }
   299  +  #DoDeploy: (#struct){
   300  +    _params: (#struct){
   301  +      manifest: ~(#DeploymentManifest)
   302  +    }
   303  +    deployment: (#struct){
   304  +      description: (#struct){
   305  +        let dep#1 = ~(#KumoriKinds.deployment)
   306  +        service: (#struct){
   307  +          description: (#struct){
   308               let configed#2 = (_|_){
   309                 // [eval]
   310                 labstr: (_|_){
   311  @@ -106,7 +48,7 @@
   312                 }
   313               }
   314               role: (_|_){
   315  -              // [eval] #DoDeploy.deployment.description.service.description.role: undefined field: role:
   316  +              // [incomplete] #DoDeploy.deployment.description.service.description.role: undefined field: role:
   317                 //     ./in.cue:40:19
   318               }
   319             }
   320  @@ -114,16 +56,13 @@
   321         }
   322       }
   323     }
   324  -  #Configure: (_|_){
   325  -    // [eval]
   326  -    _params: (#struct){
   327  -      hsize: (#struct){
   328  -      }
   329  -    }
   330  -    service: (_|_){
   331  -      // [eval]
   332  -      description: (_|_){
   333  -        // [eval]
   334  +  #Configure: (#struct){
   335  +    _params: (#struct){
   336  +      hsize: (#struct){
   337  +      }
   338  +    }
   339  +    service: (#struct){
   340  +      description: (#struct){
   341           let configed#2 = (_|_){
   342             // [eval]
   343             labstr: (_|_){
   344  @@ -132,7 +71,7 @@
   345             }
   346           }
   347           role: (_|_){
   348  -          // [eval] #Configure.service.description.role: undefined field: role:
   349  +          // [incomplete] #Configure.service.description.role: undefined field: role:
   350             //     ./in.cue:40:19
   351           }
   352         }
   353  @@ -141,9 +80,7 @@
   354     #RelabelService: (_|_){
   355       // [eval]
   356       _params: (#struct){
   357  -      hsize: (#struct){
   358  -        $_instances: (number){ |(*(int){ 1 }, (number){ >=0 }) }
   359  -      }
   360  +      hsize: ~(#RoleSize)
   361       }
   362       out: (_|_){
   363         // [eval]
   364  @@ -157,16 +94,10 @@
   365       $_instances: (number){ |(*(int){ 1 }, (number){ >=0 }) }
   366     }
   367     #Deployment: (#struct){
   368  -    service: (#struct){
   369  -      ref: (#struct){
   370  -        kind: (string){ "service" }
   371  -      }
   372  -      description: (_|_){
   373  -        // [incomplete] #Deployment.service.description: undefined field: service:
   374  -        //     ./in.cue:5:28
   375  -      }
   376  -    }
   377  -    hsize: (#struct){
   378  +    service: ~(#ServiceManifest)
   379  +    hsize: (_|_){
   380  +      // [incomplete] #ServiceManifest.description: undefined field: service:
   381  +      //     ./in.cue:5:28
   382       }
   383     }
   384     #ServiceManifest: (#struct){
   385  -- diff/-out/evalalpha/stats<==>+out/eval/stats --
   386  diff old new
   387  --- old
   388  +++ new
   389  @@ -1,9 +1,12 @@
   390  -Leaks:  16
   391  -Freed:  117
   392  -Reused: 108
   393  -Allocs: 25
   394  -Retain: 53
   395  -
   396  -Unifications: 107
   397  -Conjuncts:    243
   398  -Disjuncts:    170
   399  +Leaks:  85
   400  +Freed:  0
   401  +Reused: 0
   402  +Allocs: 85
   403  +Retain: 0
   404  +
   405  +Unifications: 61
   406  +Conjuncts:    101
   407  +Disjuncts:    8
   408  +
   409  +CloseIDElems: 17
   410  +NumCloseIDs: 17
   411  -- out/eval/stats --
   412  Leaks:  16
   413  Freed:  117
   414  Reused: 108
   415  Allocs: 25
   416  Retain: 53
   417  
   418  Unifications: 107
   419  Conjuncts:    243
   420  Disjuncts:    170
   421  -- out/eval --
   422  Errors:
   423  #Configure.service.description.role: undefined field: role:
   424      ./in.cue:40:19
   425  #DoDeploy.deployment.description.service.description.role: undefined field: role:
   426      ./in.cue:40:19
   427  #RelabelService.out.labstr: undefined field: label:
   428      ./in.cue:51:14
   429  
   430  Result:
   431  (_|_){
   432    // [eval]
   433    #DeploymentManifest: (#struct){
   434      ref: (#struct){
   435        kind: (string){ "deployment" }
   436      }
   437      description: (#struct){
   438        service: (#struct){
   439          ref: (#struct){
   440            kind: (string){ "service" }
   441          }
   442          description: (_|_){
   443            // [incomplete] #DeploymentManifest.description.service.description: undefined field: service:
   444            //     ./in.cue:5:28
   445          }
   446        }
   447        hsize: (#struct){
   448        }
   449      }
   450    }
   451    #Manifest: (#struct){
   452      ref: (#struct){
   453        kind: (string){ |((string){ "service" }, (string){ "deployment" }) }
   454      }
   455      description: (_|_){
   456        // [incomplete] #Manifest.description: unresolved disjunction "service" | "deployment" (type string):
   457        //     ./in.cue:5:15
   458      }
   459    }
   460    #ManifestRef: (#struct){
   461      kind: (string){ |((string){ "service" }, (string){ "deployment" }) }
   462    }
   463    #KindsNames: (string){ |((string){ "service" }, (string){ "deployment" }) }
   464    #KumoriKinds: (#struct){
   465      deployment: (#struct){
   466        service: (#struct){
   467          ref: (#struct){
   468            kind: (string){ "service" }
   469          }
   470          description: (_|_){
   471            // [incomplete] #KumoriKinds.deployment.service.description: undefined field: service:
   472            //     ./in.cue:5:28
   473          }
   474        }
   475        hsize: (#struct){
   476        }
   477      }
   478    }
   479    #DoDeploy: (_|_){
   480      // [eval]
   481      _params: (#struct){
   482        manifest: (#struct){
   483          ref: (#struct){
   484            kind: (string){ "deployment" }
   485          }
   486          description: (#struct){
   487            service: (#struct){
   488              ref: (#struct){
   489                kind: (string){ "service" }
   490              }
   491              description: (_|_){
   492                // [incomplete] #DoDeploy._params.manifest.description.service.description: undefined field: service:
   493                //     ./in.cue:5:28
   494              }
   495            }
   496            hsize: (#struct){
   497            }
   498          }
   499        }
   500      }
   501      deployment: (_|_){
   502        // [eval]
   503        description: (_|_){
   504          // [eval]
   505          let dep#1 = (#struct){
   506            service: (#struct){
   507              ref: (#struct){
   508                kind: (string){ "service" }
   509              }
   510              description: (_|_){
   511                // [incomplete] #DoDeploy.deployment.description.dep.service.description: undefined field: service:
   512                //     ./in.cue:5:28
   513              }
   514            }
   515            hsize: (#struct){
   516            }
   517          }
   518          service: (_|_){
   519            // [eval]
   520            description: (_|_){
   521              // [eval]
   522              let configed#2 = (_|_){
   523                // [eval]
   524                labstr: (_|_){
   525                  // [eval] #DoDeploy.deployment.description.service.description.configed.labstr: undefined field: label:
   526                  //     ./in.cue:51:14
   527                }
   528              }
   529              role: (_|_){
   530                // [eval] #DoDeploy.deployment.description.service.description.role: undefined field: role:
   531                //     ./in.cue:40:19
   532              }
   533            }
   534          }
   535        }
   536      }
   537    }
   538    #Configure: (_|_){
   539      // [eval]
   540      _params: (#struct){
   541        hsize: (#struct){
   542        }
   543      }
   544      service: (_|_){
   545        // [eval]
   546        description: (_|_){
   547          // [eval]
   548          let configed#2 = (_|_){
   549            // [eval]
   550            labstr: (_|_){
   551              // [eval] #Configure.service.description.configed.labstr: undefined field: label:
   552              //     ./in.cue:51:14
   553            }
   554          }
   555          role: (_|_){
   556            // [eval] #Configure.service.description.role: undefined field: role:
   557            //     ./in.cue:40:19
   558          }
   559        }
   560      }
   561    }
   562    #RelabelService: (_|_){
   563      // [eval]
   564      _params: (#struct){
   565        hsize: (#struct){
   566          $_instances: (number){ |(*(int){ 1 }, (number){ >=0 }) }
   567        }
   568      }
   569      out: (_|_){
   570        // [eval]
   571        labstr: (_|_){
   572          // [eval] #RelabelService.out.labstr: undefined field: label:
   573          //     ./in.cue:51:14
   574        }
   575      }
   576    }
   577    #RoleSize: (#struct){
   578      $_instances: (number){ |(*(int){ 1 }, (number){ >=0 }) }
   579    }
   580    #Deployment: (#struct){
   581      service: (#struct){
   582        ref: (#struct){
   583          kind: (string){ "service" }
   584        }
   585        description: (_|_){
   586          // [incomplete] #Deployment.service.description: undefined field: service:
   587          //     ./in.cue:5:28
   588        }
   589      }
   590      hsize: (#struct){
   591      }
   592    }
   593    #ServiceManifest: (#struct){
   594      ref: (#struct){
   595        kind: (string){ "service" }
   596      }
   597      description: (_|_){
   598        // [incomplete] #ServiceManifest.description: undefined field: service:
   599        //     ./in.cue:5:28
   600      }
   601    }
   602  }
   603  -- diff/todo/p2 --
   604  Some incorrect error messages. The newly introduced error messages for hsize
   605  seem to be correct, though.
   606  Error paths seem wrong as a result of structure sharing.
   607  Error path now selects into let. This is probably okay, and
   608  to some extent is clearer.
   609  -- out/compile --
   610  --- in.cue
   611  {
   612    #DeploymentManifest: (〈0;#Manifest〉 & {
   613      ref: {
   614        kind: "deployment"
   615      }
   616    })
   617    #Manifest: {
   618      ref: 〈1;#ManifestRef〉
   619      description: 〈1;#KumoriKinds〉[〈0;ref〉.kind]
   620    }
   621    #ManifestRef: {
   622      kind: 〈1;#KindsNames〉
   623    }
   624    #KindsNames: ("service"|"deployment")
   625    #KumoriKinds: {
   626      deployment: 〈1;#Deployment〉
   627    }
   628    #KumoriKinds: {
   629      [string]: {
   630        ...
   631      }
   632    }
   633    #DoDeploy: {
   634      _params: {
   635        manifest: 〈2;#DeploymentManifest〉
   636      }
   637      deployment: {
   638        description: {
   639          let dep#1 = 〈2;_params〉.manifest.description
   640          service: (〈3;#Configure〉 & {
   641            _params: {
   642              hsize: 〈2;let dep#1〉.hsize
   643            }
   644          }).service
   645        }
   646      }
   647    }
   648    #Configure: {
   649      _params: {
   650        hsize: {
   651          [string]: 〈3;#RoleSize〉
   652        }
   653      }
   654      service: {
   655        description: {
   656          let configed#2 = (〈3;#RelabelService〉 & {
   657            _params: {
   658              hsize: 〈4;_params〉.hsize
   659            }
   660            role: "admin"
   661          }).out
   662          role: 〈0;let configed#2〉.role
   663        }
   664      }
   665    }
   666    #RelabelService: {
   667      _params: {
   668        hsize: 〈2;#RoleSize〉
   669      }
   670      out: {
   671        labstr: 〈1;_params〉.label
   672      }
   673    }
   674    #RoleSize: {
   675      $_instances: (>=0|*1)
   676    }
   677    #Deployment: {
   678      service: 〈1;#ServiceManifest〉
   679      hsize: {
   680        [〈1;service〉.description.#roles]: 〈2;#RoleSize〉
   681      }
   682    }
   683    #ServiceManifest: (〈0;#Manifest〉 & {
   684      ref: {
   685        kind: "service"
   686      }
   687    })
   688  }