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

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: combined definitions
     4  #evalPartial
     5  -- in.cue --
     6  // Allow combining of structs within a definition
     7  #D1: {
     8  	env: a: "A"
     9  	env: b: "B"
    10  	#def: {a: "A"}
    11  	#def: {b: "B"}
    12  }
    13  
    14  d1: #D1 & {env: c: "C"}
    15  
    16  #D2: {
    17  	a: int
    18  }
    19  #D2: {
    20  	b: int
    21  }
    22  
    23  #D3: {
    24  	env: a: "A"
    25  }
    26  #D3: {
    27  	env: b: "B"
    28  }
    29  
    30  #D4: {
    31  	env: #DC
    32  	env: b: int
    33  }
    34  
    35  #DC: {a: int}
    36  -- out/def --
    37  // Allow combining of structs within a definition
    38  #D1: {
    39  	env: {
    40  		a: "A"
    41  		b: "B"
    42  	}
    43  	#def: {
    44  		a: "A"
    45  		b: "B"
    46  	}
    47  }
    48  d1: #D1 & {
    49  	env: {
    50  		c: "C"
    51  	}
    52  }
    53  #D2: {
    54  	a: int
    55  	b: int
    56  }
    57  #D3: {
    58  	env: {
    59  		a: "A"
    60  		b: "B"
    61  	}
    62  }
    63  #D4: {
    64  	env: _|_ // field "b" not allowed in closed struct
    65  }
    66  #DC: {
    67  	a: int
    68  }
    69  -- out/legacy-debug --
    70  <0>{#D1: <1>C{env: <2>C{a: "A", b: "B"}, #def: <3>C{a: "A", b: "B"}}, d1: <4>C{env: _|_("C":field "c" not allowed in closed struct), #def: <5>C{a: "A", b: "B"}}, #D2: <6>C{a: int, b: int}, #D3: <7>C{env: <8>C{a: "A", b: "B"}}, #D4: <9>C{env: _|_(int:field "b" not allowed in closed struct)}, #DC: <10>C{a: int}}
    71  -- out/compile --
    72  --- in.cue
    73  {
    74    #D1: {
    75      env: {
    76        a: "A"
    77      }
    78      env: {
    79        b: "B"
    80      }
    81      #def: {
    82        a: "A"
    83      }
    84      #def: {
    85        b: "B"
    86      }
    87    }
    88    d1: (〈0;#D1〉 & {
    89      env: {
    90        c: "C"
    91      }
    92    })
    93    #D2: {
    94      a: int
    95    }
    96    #D2: {
    97      b: int
    98    }
    99    #D3: {
   100      env: {
   101        a: "A"
   102      }
   103    }
   104    #D3: {
   105      env: {
   106        b: "B"
   107      }
   108    }
   109    #D4: {
   110      env: 〈1;#DC〉
   111      env: {
   112        b: int
   113      }
   114    }
   115    #DC: {
   116      a: int
   117    }
   118  }
   119  -- out/eval/stats --
   120  Leaks:  0
   121  Freed:  29
   122  Reused: 24
   123  Allocs: 5
   124  Retain: 1
   125  
   126  Unifications: 29
   127  Conjuncts:    41
   128  Disjuncts:    30
   129  -- out/evalalpha --
   130  Errors:
   131  #D4.env.b: field not allowed:
   132      ./in.cue:27:7
   133  d1.env.c: field not allowed:
   134      ./in.cue:9:17
   135  
   136  Result:
   137  (_|_){
   138    // [eval]
   139    #D1: (#struct){
   140      env: (#struct){
   141        a: (string){ "A" }
   142        b: (string){ "B" }
   143      }
   144      #def: (#struct){
   145        a: (string){ "A" }
   146        b: (string){ "B" }
   147      }
   148    }
   149    d1: (_|_){
   150      // [eval]
   151      env: (_|_){
   152        // [eval]
   153        c: (_|_){
   154          // [eval] d1.env.c: field not allowed:
   155          //     ./in.cue:9:17
   156        }
   157        a: (string){ "A" }
   158        b: (string){ "B" }
   159      }
   160      #def: (#struct){
   161        a: (string){ "A" }
   162        b: (string){ "B" }
   163      }
   164    }
   165    #D2: (#struct){
   166      a: (int){ int }
   167      b: (int){ int }
   168    }
   169    #D3: (#struct){
   170      env: (#struct){
   171        a: (string){ "A" }
   172        b: (string){ "B" }
   173      }
   174    }
   175    #D4: (_|_){
   176      // [eval]
   177      env: (_|_){
   178        // [eval]
   179        b: (_|_){
   180          // [eval] #D4.env.b: field not allowed:
   181          //     ./in.cue:27:7
   182        }
   183        a: (int){ int }
   184      }
   185    }
   186    #DC: (#struct){
   187      a: (int){ int }
   188    }
   189  }
   190  -- diff/-out/evalalpha<==>+out/eval --
   191  diff old new
   192  --- old
   193  +++ new
   194  @@ -1,12 +1,7 @@
   195   Errors:
   196   #D4.env.b: field not allowed:
   197  -    ./in.cue:26:7
   198       ./in.cue:27:7
   199  -    ./in.cue:30:6
   200   d1.env.c: field not allowed:
   201  -    ./in.cue:3:7
   202  -    ./in.cue:4:7
   203  -    ./in.cue:9:5
   204       ./in.cue:9:17
   205   
   206   Result:
   207  @@ -26,15 +21,12 @@
   208       // [eval]
   209       env: (_|_){
   210         // [eval]
   211  -      a: (string){ "A" }
   212  -      b: (string){ "B" }
   213         c: (_|_){
   214           // [eval] d1.env.c: field not allowed:
   215  -        //     ./in.cue:3:7
   216  -        //     ./in.cue:4:7
   217  -        //     ./in.cue:9:5
   218           //     ./in.cue:9:17
   219         }
   220  +      a: (string){ "A" }
   221  +      b: (string){ "B" }
   222       }
   223       #def: (#struct){
   224         a: (string){ "A" }
   225  @@ -55,13 +47,11 @@
   226       // [eval]
   227       env: (_|_){
   228         // [eval]
   229  -      a: (int){ int }
   230         b: (_|_){
   231           // [eval] #D4.env.b: field not allowed:
   232  -        //     ./in.cue:26:7
   233           //     ./in.cue:27:7
   234  -        //     ./in.cue:30:6
   235  -      }
   236  +      }
   237  +      a: (int){ int }
   238       }
   239     }
   240     #DC: (#struct){
   241  -- diff/todo/p2 --
   242  Missing positions
   243  -- diff/todo/p3 --
   244  Reordering
   245  -- out/eval --
   246  Errors:
   247  #D4.env.b: field not allowed:
   248      ./in.cue:26:7
   249      ./in.cue:27:7
   250      ./in.cue:30:6
   251  d1.env.c: field not allowed:
   252      ./in.cue:3:7
   253      ./in.cue:4:7
   254      ./in.cue:9:5
   255      ./in.cue:9:17
   256  
   257  Result:
   258  (_|_){
   259    // [eval]
   260    #D1: (#struct){
   261      env: (#struct){
   262        a: (string){ "A" }
   263        b: (string){ "B" }
   264      }
   265      #def: (#struct){
   266        a: (string){ "A" }
   267        b: (string){ "B" }
   268      }
   269    }
   270    d1: (_|_){
   271      // [eval]
   272      env: (_|_){
   273        // [eval]
   274        a: (string){ "A" }
   275        b: (string){ "B" }
   276        c: (_|_){
   277          // [eval] d1.env.c: field not allowed:
   278          //     ./in.cue:3:7
   279          //     ./in.cue:4:7
   280          //     ./in.cue:9:5
   281          //     ./in.cue:9:17
   282        }
   283      }
   284      #def: (#struct){
   285        a: (string){ "A" }
   286        b: (string){ "B" }
   287      }
   288    }
   289    #D2: (#struct){
   290      a: (int){ int }
   291      b: (int){ int }
   292    }
   293    #D3: (#struct){
   294      env: (#struct){
   295        a: (string){ "A" }
   296        b: (string){ "B" }
   297      }
   298    }
   299    #D4: (_|_){
   300      // [eval]
   301      env: (_|_){
   302        // [eval]
   303        a: (int){ int }
   304        b: (_|_){
   305          // [eval] #D4.env.b: field not allowed:
   306          //     ./in.cue:26:7
   307          //     ./in.cue:27:7
   308          //     ./in.cue:30:6
   309        }
   310      }
   311    }
   312    #DC: (#struct){
   313      a: (int){ int }
   314    }
   315  }