cuelang.org/go@v0.13.0/cue/testdata/definitions/032_definitions_with_embedding.txtar (about)

     1  #name: definitions with embedding
     2  #evalPartial
     3  -- in.cue --
     4  #E: {
     5  	a: {b: int}
     6  }
     7  
     8  #S: {
     9  	#E
    10  	a: {c: int}
    11  	b: 3
    12  }
    13  
    14  // adding a field to a nested struct that is closed.
    15  #e1: #S & {a: d: 4}
    16  
    17  // literal struct not closed until after unification.
    18  #v1: #S & {a: c: 4}
    19  -- out/def --
    20  #E: {
    21  	a: {
    22  		b: int
    23  	}
    24  }
    25  #S: {
    26  	a: {
    27  		c: int
    28  	}
    29  	b: 3
    30  	#E
    31  }
    32  
    33  // adding a field to a nested struct that is closed.
    34  #e1: #S & {
    35  	a: {
    36  		d: 4
    37  	}
    38  }
    39  
    40  // literal struct not closed until after unification.
    41  #v1: #S & {
    42  	a: {
    43  		c: 4
    44  	}
    45  }
    46  -- out/export --
    47  
    48  -- out/yaml --
    49  {}
    50  -- out/json --
    51  {}
    52  -- out/legacy-debug --
    53  <0>{#E: <1>C{a: <2>C{b: int}}, #S: <3>C{a: <4>C{b: int, c: int}, b: 3}, #e1: <5>C{a: _|_(4:field "d" not allowed in closed struct), b: 3}, #v1: <6>C{a: <7>C{b: int, c: 4}, b: 3}}
    54  -- out/compile --
    55  --- in.cue
    56  {
    57    #E: {
    58      a: {
    59        b: int
    60      }
    61    }
    62    #S: {
    63      〈1;#E〉
    64      a: {
    65        c: int
    66      }
    67      b: 3
    68    }
    69    #e1: (〈0;#S〉 & {
    70      a: {
    71        d: 4
    72      }
    73    })
    74    #v1: (〈0;#S〉 & {
    75      a: {
    76        c: 4
    77      }
    78    })
    79  }
    80  -- out/eval/stats --
    81  Leaks:  0
    82  Freed:  20
    83  Reused: 16
    84  Allocs: 4
    85  Retain: 0
    86  
    87  Unifications: 20
    88  Conjuncts:    36
    89  Disjuncts:    20
    90  -- out/evalalpha --
    91  Errors:
    92  #e1.a.d: field not allowed:
    93      ./in.cue:12:15
    94  
    95  Result:
    96  (_|_){
    97    // [eval]
    98    #E: (#struct){
    99      a: (#struct){
   100        b: (int){ int }
   101      }
   102    }
   103    #S: (#struct){
   104      a: (#struct){
   105        c: (int){ int }
   106        b: (int){ int }
   107      }
   108      b: (int){ 3 }
   109    }
   110    #e1: (_|_){
   111      // [eval]
   112      a: (_|_){
   113        // [eval]
   114        d: (_|_){
   115          // [eval] #e1.a.d: field not allowed:
   116          //     ./in.cue:12:15
   117        }
   118        c: (int){ int }
   119        b: (int){ int }
   120      }
   121      b: (int){ 3 }
   122    }
   123    #v1: (#struct){
   124      a: (#struct){
   125        c: (int){ 4 }
   126        b: (int){ int }
   127      }
   128      b: (int){ 3 }
   129    }
   130  }
   131  -- diff/-out/evalalpha<==>+out/eval --
   132  diff old new
   133  --- old
   134  +++ new
   135  @@ -1,9 +1,5 @@
   136   Errors:
   137   #e1.a.d: field not allowed:
   138  -    ./in.cue:2:5
   139  -    ./in.cue:6:2
   140  -    ./in.cue:7:5
   141  -    ./in.cue:12:6
   142       ./in.cue:12:15
   143   
   144   Result:
   145  @@ -16,8 +12,8 @@
   146     }
   147     #S: (#struct){
   148       a: (#struct){
   149  -      b: (int){ int }
   150  -      c: (int){ int }
   151  +      c: (int){ int }
   152  +      b: (int){ int }
   153       }
   154       b: (int){ 3 }
   155     }
   156  @@ -25,23 +21,19 @@
   157       // [eval]
   158       a: (_|_){
   159         // [eval]
   160  -      b: (int){ int }
   161  -      c: (int){ int }
   162         d: (_|_){
   163           // [eval] #e1.a.d: field not allowed:
   164  -        //     ./in.cue:2:5
   165  -        //     ./in.cue:6:2
   166  -        //     ./in.cue:7:5
   167  -        //     ./in.cue:12:6
   168           //     ./in.cue:12:15
   169         }
   170  +      c: (int){ int }
   171  +      b: (int){ int }
   172       }
   173       b: (int){ 3 }
   174     }
   175     #v1: (#struct){
   176       a: (#struct){
   177  -      b: (int){ int }
   178         c: (int){ 4 }
   179  +      b: (int){ int }
   180       }
   181       b: (int){ 3 }
   182     }
   183  -- diff/todo/p2 --
   184  Reordering / missing positions.
   185  -- out/eval --
   186  Errors:
   187  #e1.a.d: field not allowed:
   188      ./in.cue:2:5
   189      ./in.cue:6:2
   190      ./in.cue:7:5
   191      ./in.cue:12:6
   192      ./in.cue:12:15
   193  
   194  Result:
   195  (_|_){
   196    // [eval]
   197    #E: (#struct){
   198      a: (#struct){
   199        b: (int){ int }
   200      }
   201    }
   202    #S: (#struct){
   203      a: (#struct){
   204        b: (int){ int }
   205        c: (int){ int }
   206      }
   207      b: (int){ 3 }
   208    }
   209    #e1: (_|_){
   210      // [eval]
   211      a: (_|_){
   212        // [eval]
   213        b: (int){ int }
   214        c: (int){ int }
   215        d: (_|_){
   216          // [eval] #e1.a.d: field not allowed:
   217          //     ./in.cue:2:5
   218          //     ./in.cue:6:2
   219          //     ./in.cue:7:5
   220          //     ./in.cue:12:6
   221          //     ./in.cue:12:15
   222        }
   223      }
   224      b: (int){ 3 }
   225    }
   226    #v1: (#struct){
   227      a: (#struct){
   228        b: (int){ int }
   229        c: (int){ 4 }
   230      }
   231      b: (int){ 3 }
   232    }
   233  }