cuelang.org/go@v0.13.0/cue/testdata/resolve/030_definitions_with_disjunctions.txtar (about)

     1  #name: definitions with disjunctions
     2  #evalPartial
     3  -- in.cue --
     4  #Foo: {
     5  	field: int
     6  
     7  	{a: 1} |
     8  	{b: 2}
     9  }
    10  
    11  foo: #Foo
    12  foo: {a: 1}
    13  
    14  bar: #Foo
    15  bar: {c: 2}
    16  
    17  baz: #Foo
    18  baz: {b: 2}
    19  -- out/def --
    20  #Foo: {
    21  	field: int
    22  	a:     1
    23  } | {
    24  	field: int
    25  	b:     2
    26  }
    27  foo: #Foo & {
    28  	a: 1
    29  }
    30  bar: _|_ // 
    31  baz: #Foo & {
    32  	b: 2
    33  }
    34  -- out/legacy-debug --
    35  <0>{#Foo: (<1>C{field: int, a: 1} | <2>C{field: int, b: 2}), foo: <3>C{field: int, a: 1}, bar: _|_(2:empty disjunction: field "c" not allowed in closed struct), baz: <4>C{field: int, b: 2}}
    36  -- out/compile --
    37  --- in.cue
    38  {
    39    #Foo: {
    40      field: int
    41      ({
    42        a: 1
    43      }|{
    44        b: 2
    45      })
    46    }
    47    foo: 〈0;#Foo〉
    48    foo: {
    49      a: 1
    50    }
    51    bar: 〈0;#Foo〉
    52    bar: {
    53      c: 2
    54    }
    55    baz: 〈0;#Foo〉
    56    baz: {
    57      b: 2
    58    }
    59  }
    60  -- out/eval/stats --
    61  Leaks:  0
    62  Freed:  33
    63  Reused: 28
    64  Allocs: 5
    65  Retain: 0
    66  
    67  Unifications: 25
    68  Conjuncts:    45
    69  Disjuncts:    33
    70  -- out/evalalpha --
    71  Errors:
    72  bar.c: field not allowed:
    73      ./in.cue:12:7
    74  
    75  Result:
    76  (_|_){
    77    // [eval]
    78    #Foo: (#struct){ |((#struct){
    79        field: (int){ int }
    80        a: (int){ 1 }
    81      }, (#struct){
    82        field: (int){ int }
    83        b: (int){ 2 }
    84      }) }
    85    foo: (#struct){
    86      a: (int){ 1 }
    87      field: (int){ int }
    88    }
    89    bar: (_|_){
    90      // [eval] bar.c: field not allowed:
    91      //     ./in.cue:12:7
    92      c: (int){ 2 }
    93      field: (int){ int }
    94    }
    95    baz: (#struct){
    96      b: (int){ 2 }
    97      field: (int){ int }
    98    }
    99  }
   100  -- diff/-out/evalalpha<==>+out/eval --
   101  diff old new
   102  --- old
   103  +++ new
   104  @@ -1,8 +1,5 @@
   105   Errors:
   106   bar.c: field not allowed:
   107  -    ./in.cue:1:7
   108  -    ./in.cue:4:2
   109  -    ./in.cue:11:6
   110       ./in.cue:12:7
   111   
   112   Result:
   113  @@ -16,28 +13,17 @@
   114         b: (int){ 2 }
   115       }) }
   116     foo: (#struct){
   117  -    field: (int){ int }
   118       a: (int){ 1 }
   119  +    field: (int){ int }
   120     }
   121     bar: (_|_){
   122       // [eval] bar.c: field not allowed:
   123  -    //     ./in.cue:1:7
   124  -    //     ./in.cue:4:2
   125  -    //     ./in.cue:11:6
   126       //     ./in.cue:12:7
   127  -    field: (int){ int }
   128  -    c: (_|_){
   129  -      // [eval] bar.c: field not allowed:
   130  -      //     ./in.cue:1:7
   131  -      //     ./in.cue:4:2
   132  -      //     ./in.cue:5:2
   133  -      //     ./in.cue:11:6
   134  -      //     ./in.cue:12:7
   135  -    }
   136  -    b: (int){ 2 }
   137  +    c: (int){ 2 }
   138  +    field: (int){ int }
   139     }
   140     baz: (#struct){
   141  -    field: (int){ int }
   142  -    b: (int){ 2 }
   143  +    b: (int){ 2 }
   144  +    field: (int){ int }
   145     }
   146   }
   147  -- diff/todo/p2 --
   148  Missing error positions and reorderings.
   149  -- diff/explanation --
   150  bar.b: removed in new evaluator. This is correct. In the old
   151  evaluator this addition was spurious.
   152  -- out/eval --
   153  Errors:
   154  bar.c: field not allowed:
   155      ./in.cue:1:7
   156      ./in.cue:4:2
   157      ./in.cue:11:6
   158      ./in.cue:12:7
   159  
   160  Result:
   161  (_|_){
   162    // [eval]
   163    #Foo: (#struct){ |((#struct){
   164        field: (int){ int }
   165        a: (int){ 1 }
   166      }, (#struct){
   167        field: (int){ int }
   168        b: (int){ 2 }
   169      }) }
   170    foo: (#struct){
   171      field: (int){ int }
   172      a: (int){ 1 }
   173    }
   174    bar: (_|_){
   175      // [eval] bar.c: field not allowed:
   176      //     ./in.cue:1:7
   177      //     ./in.cue:4:2
   178      //     ./in.cue:11:6
   179      //     ./in.cue:12:7
   180      field: (int){ int }
   181      c: (_|_){
   182        // [eval] bar.c: field not allowed:
   183        //     ./in.cue:1:7
   184        //     ./in.cue:4:2
   185        //     ./in.cue:5:2
   186        //     ./in.cue:11:6
   187        //     ./in.cue:12:7
   188      }
   189      b: (int){ 2 }
   190    }
   191    baz: (#struct){
   192      field: (int){ int }
   193      b: (int){ 2 }
   194    }
   195  }