cuelang.org/go@v0.10.1/cue/testdata/definitions/issue359.txtar (about)

     1  -- in.cue --
     2  #simple: {
     3  	peso: *1 | int
     4  	edad: *2 | int
     5  }
     6  
     7  // Second struct is not considered closed, as expected
     8  good: #simple & {
     9  	peso: 4
    10  }
    11  
    12  #complex: {
    13  	things: [string]: #simple
    14  }
    15  
    16  // Still, no closedness issue in the second struct
    17  #many: #complex & {
    18  	things: hola: peso: 2
    19  	things: sol: peso:  3
    20  }
    21  
    22  // Inner struct in second struct IS considered closed: why?
    23  bad: #many & {
    24  	things: hola: peso: 2
    25  }
    26  
    27  // non-definition equivalent
    28  many: #complex & {
    29  	things: hola: peso: 2
    30  	things: sol: peso:  3
    31  }
    32  
    33  // Now inner struct on second struct is NOT considered closed
    34  notbad: many & {
    35  	things: hola: peso: 2
    36  }
    37  -- out/eval/stats --
    38  Leaks:  0
    39  Freed:  81
    40  Reused: 74
    41  Allocs: 7
    42  Retain: 0
    43  
    44  Unifications: 41
    45  Conjuncts:    134
    46  Disjuncts:    81
    47  -- out/eval --
    48  (struct){
    49    #simple: (#struct){
    50      peso: (int){ |(*(int){ 1 }, (int){ int }) }
    51      edad: (int){ |(*(int){ 2 }, (int){ int }) }
    52    }
    53    good: (#struct){
    54      peso: (int){ 4 }
    55      edad: (int){ |(*(int){ 2 }, (int){ int }) }
    56    }
    57    #complex: (#struct){
    58      things: (#struct){
    59      }
    60    }
    61    #many: (#struct){
    62      things: (#struct){
    63        hola: (#struct){
    64          peso: (int){ 2 }
    65          edad: (int){ |(*(int){ 2 }, (int){ int }) }
    66        }
    67        sol: (#struct){
    68          peso: (int){ 3 }
    69          edad: (int){ |(*(int){ 2 }, (int){ int }) }
    70        }
    71      }
    72    }
    73    bad: (#struct){
    74      things: (#struct){
    75        hola: (#struct){
    76          peso: (int){ 2 }
    77          edad: (int){ |(*(int){ 2 }, (int){ int }) }
    78        }
    79        sol: (#struct){
    80          peso: (int){ 3 }
    81          edad: (int){ |(*(int){ 2 }, (int){ int }) }
    82        }
    83      }
    84    }
    85    many: (#struct){
    86      things: (#struct){
    87        hola: (#struct){
    88          peso: (int){ 2 }
    89          edad: (int){ |(*(int){ 2 }, (int){ int }) }
    90        }
    91        sol: (#struct){
    92          peso: (int){ 3 }
    93          edad: (int){ |(*(int){ 2 }, (int){ int }) }
    94        }
    95      }
    96    }
    97    notbad: (#struct){
    98      things: (#struct){
    99        hola: (#struct){
   100          peso: (int){ 2 }
   101          edad: (int){ |(*(int){ 2 }, (int){ int }) }
   102        }
   103        sol: (#struct){
   104          peso: (int){ 3 }
   105          edad: (int){ |(*(int){ 2 }, (int){ int }) }
   106        }
   107      }
   108    }
   109  }
   110  -- out/compile --
   111  --- in.cue
   112  {
   113    #simple: {
   114      peso: (*1|int)
   115      edad: (*2|int)
   116    }
   117    good: (〈0;#simple〉 & {
   118      peso: 4
   119    })
   120    #complex: {
   121      things: {
   122        [string]: 〈2;#simple〉
   123      }
   124    }
   125    #many: (〈0;#complex〉 & {
   126      things: {
   127        hola: {
   128          peso: 2
   129        }
   130      }
   131      things: {
   132        sol: {
   133          peso: 3
   134        }
   135      }
   136    })
   137    bad: (〈0;#many〉 & {
   138      things: {
   139        hola: {
   140          peso: 2
   141        }
   142      }
   143    })
   144    many: (〈0;#complex〉 & {
   145      things: {
   146        hola: {
   147          peso: 2
   148        }
   149      }
   150      things: {
   151        sol: {
   152          peso: 3
   153        }
   154      }
   155    })
   156    notbad: (〈0;many〉 & {
   157      things: {
   158        hola: {
   159          peso: 2
   160        }
   161      }
   162    })
   163  }