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

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