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

     1  // Tests fields.go
     2  
     3  -- in.cue --
     4  // TODO: reorganize ordered on what is tested by name. E.g.
     5  // insertion: longPath: ok: p1: {
     6  //     a: .... @fail()
     7  // }
     8  
     9  ok: t1: {
    10  	c: #R
    11  	c: [{b: int}]
    12  	#R: [...]
    13  }
    14  
    15  ok: t2: {
    16  	#A: _
    17  	l: #A
    18  	l: f: "hi"
    19  }
    20  
    21  ok: t3: {
    22  	#A: f: {...}
    23  	#A1: { #A }
    24  	s: [string]: #A1
    25  	s: foo: f: d: foo: 1
    26  }
    27  
    28  ok: t4: {
    29  	#T: { a: b: 1 }
    30  	W: {
    31  		{#T}
    32  		b: c: 2
    33  	}
    34  }
    35  
    36  ok: t5: {
    37  	// TODO: move to err
    38  	#A: {
    39  		Common
    40  		_
    41  	}
    42  	Common: { }
    43  	x: #A
    44  	x: c: int
    45  }
    46  
    47  ok: t6: {
    48  	#A: {
    49  		Common
    50  		...
    51  	}
    52  	Common: { }
    53  	x: #A
    54  	x: c: int
    55  }
    56  
    57  ok: t7: {
    58  	a: {#A, #B}
    59  	#A: b: f: 1
    60  	#B: b: g: 1
    61  }
    62  
    63  ok: t8: {
    64  	// TODO: this should pass
    65  	foo: #X
    66  	#X: {
    67  		a: b: c: C: 1
    68  		for k, _ in a {
    69  			// dynamic field causes insertion one level higher. This causes
    70  			// b to be inserted in a, after it has been referenced.
    71  			a: (k): c: D: 2
    72  		}
    73  	}
    74  }
    75  
    76  ok: t9: {
    77  	c: #R
    78  	c: [{b: int}]
    79  	#R: [...]
    80  }
    81  
    82  ok: t10: {
    83  	#A: _ // top should allow everything
    84  	l: #A
    85  	l: f: "hi"
    86  }
    87  
    88  ok: t11: {
    89  	// indirections
    90  	#A: f: {...}
    91  	#A1: { #A }
    92  	s: [string]: #A1
    93  	s: foo: f: d: foo: "bar" // should pass
    94  }
    95  
    96  ok: t12: {
    97  	// nested embedding
    98  	#T: { a: b: 1 }
    99  	W: {
   100  		{#T}
   101  		b: c: 2
   102  	}
   103  }
   104  
   105  ok: t13: {
   106  	// TODO: move to err
   107  
   108  	// top DOES NOT open up
   109  	#A: {
   110  		Common
   111  		_
   112  	}
   113  	Common: { }
   114  	x: #A
   115  	x: c: int
   116  }
   117  
   118  ok: t14: {
   119  	// ellipsis opens up
   120  	#A: {
   121  		Common
   122  		...
   123  	}
   124  	Common: { }
   125  	x: #A
   126  	x: c: int
   127  }
   128  
   129  // TODO: move this test to "ok": _ means any and implicitly defines all fields
   130  // to be present as optional fields with _, recursively (as long as the type
   131  // has not been picked to be non-struct).
   132  // This was not observed in V2, but is now observed in V3. We should probably
   133  // either allow for an error variant that only "allows" all fields but does not
   134  // define them as optional top, or rethink the closedness model altogether.
   135  err: t1: {
   136  	#D: _ & {a: 2}
   137  	a: #D
   138  	a: disallowed: 1
   139  }
   140  
   141  err: t2: {
   142  	#S: { { c: d: 1 } }
   143  	V: #S
   144  	V: { c: e:  1 }
   145  }
   146  
   147  err: t3: p1: {
   148  	#D: {}
   149  	a: #D
   150  	a: c: "C"
   151  }
   152  
   153  err: t3: p2: {
   154  	#D: b: {}
   155  	a: #D
   156  	a: b: c: "C"
   157  }
   158  
   159  err: t4: {
   160  	a: #A
   161  	#A: b: f: 1
   162  	a: b: h: 1
   163  }
   164  
   165  err: t5: {
   166  	// TODO: this should fail
   167  	a: {#A, #B}
   168  	#A: b: f: 1
   169  	#B: b: g: 1
   170  	b: a
   171  	b: b: h: 1 // only an error here
   172  }
   173  
   174  err: t6: {
   175  	// TODO: this should fail
   176  	a: {#A, #B}
   177  	#A: b: c: d: e: f: 1
   178  	#B: b: c: d: e: g: 1
   179  	b: a
   180  	b: b: c: d: e: h: 1 // only an error here
   181  }
   182  
   183  // TODO: move this test to "ok": _ means any and implicitly defines all fields
   184  // to be present as optional fields with _, recursively (as long as the type
   185  // has not been picked to be non-struct).
   186  // This was not observed in V2, but is now observed in V3. We should probably
   187  // either allow for an error variant that only "allows" all fields but does not
   188  // define them as optional top, or rethink the closedness model altogether.
   189  err: t7: {
   190  	#D: _ & {a: 2}
   191  	a: #D
   192  	a: b: 1
   193  }
   194  
   195  err: t8: {
   196  	// nested embedding
   197  	#S: { { c: d: 1 } }
   198  	V: #S
   199  	V: { c: e:  1 } // Should fail
   200  }
   201  -- validators.cue --
   202  import "struct"
   203  
   204  // Validators represent top, but in the case of some validators, we should not
   205  // allow a struct to "close" it. Basically, we any validator that takes a
   206  // schema as argument (is marked as NonConcrete) will open up the struct.
   207  //
   208  // TODO: we should aim to eliminate this discrepancy in the closedness redesign.
   209  validator: open: {
   210  	#Schema: {
   211  		matchN(1, [#x])
   212  		#x: trailingComma?: "all"
   213  	}
   214  	data: trailingComma: "all"
   215  	data: #Schema
   216  }
   217  
   218  validator: keepClosed: {
   219  	#X: {
   220  		struct.MaxFields(1)
   221  		a?: int
   222  		b?: int
   223  	}
   224  	x: #X
   225  	x: c: 1
   226  }
   227  -- issue1830.cue --
   228  issue1830: {
   229  	#x: {
   230  		y: {
   231  			z?: {
   232  				name: string
   233  			}
   234  		}
   235  	}
   236  
   237  	egs: {
   238  		x1: (#x & {y: z: _}).y.z & {
   239  			name: "blah"
   240  			age1: 5
   241  		}
   242  		x2: (#x.y & {z: _}).z & {
   243  			name: "blah"
   244  			age2: 5
   245  		}
   246  	}
   247  }
   248  -- issue3491.cue --
   249  issue3491: {
   250  	#Schema: field?: {}
   251    
   252  	a: #Schema & {
   253  	  field: {}
   254  	}
   255    
   256  	a: b
   257  	b: #Extra: {}
   258  }
   259  -- out/evalalpha/stats --
   260  Leaks:  244
   261  Freed:  0
   262  Reused: 0
   263  Allocs: 244
   264  Retain: 0
   265  
   266  Unifications: 241
   267  Conjuncts:    428
   268  Disjuncts:    0
   269  
   270  CloseIDElems: 1332
   271  NumCloseIDs: 140
   272  -- diff/-out/evalalpha/stats<==>+out/eval/stats --
   273  diff old new
   274  --- old
   275  +++ new
   276  @@ -1,9 +1,12 @@
   277  -Leaks:  5
   278  -Freed:  239
   279  -Reused: 232
   280  -Allocs: 12
   281  -Retain: 25
   282  -
   283  -Unifications: 244
   284  -Conjuncts:    441
   285  -Disjuncts:    263
   286  +Leaks:  244
   287  +Freed:  0
   288  +Reused: 0
   289  +Allocs: 244
   290  +Retain: 0
   291  +
   292  +Unifications: 241
   293  +Conjuncts:    428
   294  +Disjuncts:    0
   295  +
   296  +CloseIDElems: 1332
   297  +NumCloseIDs: 140
   298  -- out/eval/stats --
   299  Leaks:  5
   300  Freed:  239
   301  Reused: 232
   302  Allocs: 12
   303  Retain: 25
   304  
   305  Unifications: 244
   306  Conjuncts:    441
   307  Disjuncts:    263
   308  -- out/evalalpha --
   309  Errors:
   310  err.t1.a.disallowed: field not allowed:
   311      ./in.cue:135:5
   312  err.t2.V.c.e: field not allowed:
   313      ./in.cue:141:10
   314  err.t3.p1.a.c: field not allowed:
   315      ./in.cue:147:5
   316  err.t3.p2.a.b.c: field not allowed:
   317      ./in.cue:153:8
   318  err.t4.a.b.h: field not allowed:
   319      ./in.cue:159:8
   320  err.t5.b.b.h: field not allowed:
   321      ./in.cue:168:8
   322  err.t6.b.b.c.d.e.h: field not allowed:
   323      ./in.cue:177:17
   324  err.t7.a.b: field not allowed:
   325      ./in.cue:189:5
   326  err.t8.V.c.e: field not allowed:
   327      ./in.cue:196:10
   328  ok.t13.x.c: field not allowed:
   329      ./in.cue:112:5
   330  ok.t5.x.c: field not allowed:
   331      ./in.cue:41:5
   332  validator.keepClosed.x.c: field not allowed:
   333      ./validators.cue:24:5
   334  
   335  Result:
   336  (_|_){
   337    // [eval]
   338    ok: (_|_){
   339      // [eval]
   340      t1: (struct){
   341        c: (#list){
   342          0: (#struct){
   343            b: (int){ int }
   344          }
   345        }
   346        #R: (list){
   347        }
   348      }
   349      t2: (struct){
   350        #A: (_){ _ }
   351        l: (#struct){
   352          f: (string){ "hi" }
   353        }
   354      }
   355      t3: (struct){
   356        #A: (#struct){
   357          f: (#struct){
   358          }
   359        }
   360        #A1: (#struct){
   361          f: (#struct){
   362          }
   363        }
   364        s: (struct){
   365          foo: (#struct){
   366            f: (#struct){
   367              d: (struct){
   368                foo: (int){ 1 }
   369              }
   370            }
   371          }
   372        }
   373      }
   374      t4: (struct){
   375        #T: (#struct){
   376          a: (#struct){
   377            b: (int){ 1 }
   378          }
   379        }
   380        W: (#struct){
   381          b: (struct){
   382            c: (int){ 2 }
   383          }
   384          a: (#struct){
   385            b: (int){ 1 }
   386          }
   387        }
   388      }
   389      t5: (_|_){
   390        // [eval]
   391        #A: (#struct){
   392        }
   393        Common: (struct){
   394        }
   395        x: (_|_){
   396          // [eval]
   397          c: (_|_){
   398            // [eval] ok.t5.x.c: field not allowed:
   399            //     ./in.cue:41:5
   400          }
   401        }
   402      }
   403      t6: (struct){
   404        #A: (#struct){
   405        }
   406        Common: (struct){
   407        }
   408        x: (#struct){
   409          c: (int){ int }
   410        }
   411      }
   412      t7: (struct){
   413        a: (#struct){
   414          b: (#struct){
   415            f: (int){ 1 }
   416            g: (int){ 1 }
   417          }
   418        }
   419        #A: (#struct){
   420          b: (#struct){
   421            f: (int){ 1 }
   422          }
   423        }
   424        #B: (#struct){
   425          b: (#struct){
   426            g: (int){ 1 }
   427          }
   428        }
   429      }
   430      t8: (struct){
   431        foo: ~(ok.t8.#X)
   432        #X: (#struct){
   433          a: (#struct){
   434            b: (#struct){
   435              c: (#struct){
   436                C: (int){ 1 }
   437                D: (int){ 2 }
   438              }
   439            }
   440          }
   441        }
   442      }
   443      t9: (struct){
   444        c: (#list){
   445          0: (#struct){
   446            b: (int){ int }
   447          }
   448        }
   449        #R: (list){
   450        }
   451      }
   452      t10: (struct){
   453        #A: (_){ _ }
   454        l: (#struct){
   455          f: (string){ "hi" }
   456        }
   457      }
   458      t11: (struct){
   459        #A: (#struct){
   460          f: (#struct){
   461          }
   462        }
   463        #A1: (#struct){
   464          f: (#struct){
   465          }
   466        }
   467        s: (struct){
   468          foo: (#struct){
   469            f: (#struct){
   470              d: (struct){
   471                foo: (string){ "bar" }
   472              }
   473            }
   474          }
   475        }
   476      }
   477      t12: (struct){
   478        #T: (#struct){
   479          a: (#struct){
   480            b: (int){ 1 }
   481          }
   482        }
   483        W: (#struct){
   484          b: (struct){
   485            c: (int){ 2 }
   486          }
   487          a: (#struct){
   488            b: (int){ 1 }
   489          }
   490        }
   491      }
   492      t13: (_|_){
   493        // [eval]
   494        #A: (#struct){
   495        }
   496        Common: (struct){
   497        }
   498        x: (_|_){
   499          // [eval]
   500          c: (_|_){
   501            // [eval] ok.t13.x.c: field not allowed:
   502            //     ./in.cue:112:5
   503          }
   504        }
   505      }
   506      t14: (struct){
   507        #A: (#struct){
   508        }
   509        Common: (struct){
   510        }
   511        x: (#struct){
   512          c: (int){ int }
   513        }
   514      }
   515    }
   516    err: (_|_){
   517      // [eval]
   518      t1: (_|_){
   519        // [eval]
   520        #D: (#struct){
   521          a: (int){ 2 }
   522        }
   523        a: (_|_){
   524          // [eval]
   525          disallowed: (_|_){
   526            // [eval] err.t1.a.disallowed: field not allowed:
   527            //     ./in.cue:135:5
   528          }
   529          a: (int){ 2 }
   530        }
   531      }
   532      t2: (_|_){
   533        // [eval]
   534        #S: (#struct){
   535          c: (#struct){
   536            d: (int){ 1 }
   537          }
   538        }
   539        V: (_|_){
   540          // [eval]
   541          c: (_|_){
   542            // [eval]
   543            e: (_|_){
   544              // [eval] err.t2.V.c.e: field not allowed:
   545              //     ./in.cue:141:10
   546            }
   547            d: (int){ 1 }
   548          }
   549        }
   550      }
   551      t3: (_|_){
   552        // [eval]
   553        p1: (_|_){
   554          // [eval]
   555          #D: (#struct){
   556          }
   557          a: (_|_){
   558            // [eval]
   559            c: (_|_){
   560              // [eval] err.t3.p1.a.c: field not allowed:
   561              //     ./in.cue:147:5
   562            }
   563          }
   564        }
   565        p2: (_|_){
   566          // [eval]
   567          #D: (#struct){
   568            b: (#struct){
   569            }
   570          }
   571          a: (_|_){
   572            // [eval]
   573            b: (_|_){
   574              // [eval]
   575              c: (_|_){
   576                // [eval] err.t3.p2.a.b.c: field not allowed:
   577                //     ./in.cue:153:8
   578              }
   579            }
   580          }
   581        }
   582      }
   583      t4: (_|_){
   584        // [eval]
   585        a: (_|_){
   586          // [eval]
   587          b: (_|_){
   588            // [eval]
   589            h: (_|_){
   590              // [eval] err.t4.a.b.h: field not allowed:
   591              //     ./in.cue:159:8
   592            }
   593            f: (int){ 1 }
   594          }
   595        }
   596        #A: (#struct){
   597          b: (#struct){
   598            f: (int){ 1 }
   599          }
   600        }
   601      }
   602      t5: (_|_){
   603        // [eval]
   604        a: (#struct){
   605          b: (#struct){
   606            f: (int){ 1 }
   607            g: (int){ 1 }
   608          }
   609        }
   610        #A: (#struct){
   611          b: (#struct){
   612            f: (int){ 1 }
   613          }
   614        }
   615        #B: (#struct){
   616          b: (#struct){
   617            g: (int){ 1 }
   618          }
   619        }
   620        b: (_|_){
   621          // [eval]
   622          b: (_|_){
   623            // [eval]
   624            h: (_|_){
   625              // [eval] err.t5.b.b.h: field not allowed:
   626              //     ./in.cue:168:8
   627            }
   628            f: (int){ 1 }
   629            g: (int){ 1 }
   630          }
   631        }
   632      }
   633      t6: (_|_){
   634        // [eval]
   635        a: (#struct){
   636          b: (#struct){
   637            c: (#struct){
   638              d: (#struct){
   639                e: (#struct){
   640                  f: (int){ 1 }
   641                  g: (int){ 1 }
   642                }
   643              }
   644            }
   645          }
   646        }
   647        #A: (#struct){
   648          b: (#struct){
   649            c: (#struct){
   650              d: (#struct){
   651                e: (#struct){
   652                  f: (int){ 1 }
   653                }
   654              }
   655            }
   656          }
   657        }
   658        #B: (#struct){
   659          b: (#struct){
   660            c: (#struct){
   661              d: (#struct){
   662                e: (#struct){
   663                  g: (int){ 1 }
   664                }
   665              }
   666            }
   667          }
   668        }
   669        b: (_|_){
   670          // [eval]
   671          b: (_|_){
   672            // [eval]
   673            c: (_|_){
   674              // [eval]
   675              d: (_|_){
   676                // [eval]
   677                e: (_|_){
   678                  // [eval]
   679                  h: (_|_){
   680                    // [eval] err.t6.b.b.c.d.e.h: field not allowed:
   681                    //     ./in.cue:177:17
   682                  }
   683                  f: (int){ 1 }
   684                  g: (int){ 1 }
   685                }
   686              }
   687            }
   688          }
   689        }
   690      }
   691      t7: (_|_){
   692        // [eval]
   693        #D: (#struct){
   694          a: (int){ 2 }
   695        }
   696        a: (_|_){
   697          // [eval]
   698          b: (_|_){
   699            // [eval] err.t7.a.b: field not allowed:
   700            //     ./in.cue:189:5
   701          }
   702          a: (int){ 2 }
   703        }
   704      }
   705      t8: (_|_){
   706        // [eval]
   707        #S: (#struct){
   708          c: (#struct){
   709            d: (int){ 1 }
   710          }
   711        }
   712        V: (_|_){
   713          // [eval]
   714          c: (_|_){
   715            // [eval]
   716            e: (_|_){
   717              // [eval] err.t8.V.c.e: field not allowed:
   718              //     ./in.cue:196:10
   719            }
   720            d: (int){ 1 }
   721          }
   722        }
   723      }
   724    }
   725    issue1830: (struct){
   726      #x: (#struct){
   727        y: (#struct){
   728          z?: (#struct){
   729            name: (string){ string }
   730          }
   731        }
   732      }
   733      egs: (struct){
   734        x1: (#struct){
   735          name: (string){ "blah" }
   736          age1: (int){ 5 }
   737        }
   738        x2: (#struct){
   739          name: (string){ "blah" }
   740          age2: (int){ 5 }
   741        }
   742      }
   743    }
   744    issue3491: (struct){
   745      #Schema: (#struct){
   746        field?: (#struct){
   747        }
   748      }
   749      a: (#struct){
   750        field: (#struct){
   751        }
   752        #Extra: (#struct){
   753        }
   754      }
   755      b: (struct){
   756        #Extra: (#struct){
   757        }
   758      }
   759    }
   760    validator: (_|_){
   761      // [eval]
   762      open: (struct){
   763        #Schema: (_){
   764          matchN(1, (#list){
   765            0: (_|_){// 〈1;#x〉
   766            }
   767          })
   768          #x: (#struct){
   769            trailingComma?: (string){ "all" }
   770          }
   771        }
   772        data: (#struct){
   773          trailingComma: (string){ "all" }
   774          #x: (#struct){
   775            trailingComma?: (string){ "all" }
   776          }
   777        }
   778      }
   779      keepClosed: (_|_){
   780        // [eval]
   781        #X: (#struct){
   782          a?: (int){ int }
   783          b?: (int){ int }
   784        }
   785        x: (_|_){
   786          // [eval]
   787          c: (_|_){
   788            // [eval] validator.keepClosed.x.c: field not allowed:
   789            //     ./validators.cue:24:5
   790          }
   791          a?: (int){ int }
   792          b?: (int){ int }
   793        }
   794      }
   795    }
   796  }
   797  -- diff/-out/evalalpha<==>+out/eval --
   798  diff old new
   799  --- old
   800  +++ new
   801  @@ -1,74 +1,28 @@
   802   Errors:
   803   err.t1.a.disallowed: field not allowed:
   804  -    ./in.cue:133:10
   805  -    ./in.cue:134:5
   806       ./in.cue:135:5
   807   err.t2.V.c.e: field not allowed:
   808  -    ./in.cue:139:8
   809  -    ./in.cue:139:13
   810  -    ./in.cue:140:5
   811       ./in.cue:141:10
   812   err.t3.p1.a.c: field not allowed:
   813  -    ./in.cue:145:6
   814  -    ./in.cue:146:5
   815       ./in.cue:147:5
   816   err.t3.p2.a.b.c: field not allowed:
   817  -    ./in.cue:151:9
   818  -    ./in.cue:152:5
   819       ./in.cue:153:8
   820   err.t4.a.b.h: field not allowed:
   821  -    ./in.cue:157:5
   822  -    ./in.cue:158:9
   823       ./in.cue:159:8
   824   err.t5.b.b.h: field not allowed:
   825  -    ./in.cue:164:6
   826  -    ./in.cue:164:10
   827  -    ./in.cue:165:9
   828  -    ./in.cue:166:9
   829  -    ./in.cue:167:5
   830       ./in.cue:168:8
   831   err.t6.b.b.c.d.e.h: field not allowed:
   832  -    ./in.cue:173:6
   833  -    ./in.cue:173:10
   834  -    ./in.cue:174:18
   835  -    ./in.cue:175:18
   836  -    ./in.cue:176:5
   837       ./in.cue:177:17
   838   err.t7.a.b: field not allowed:
   839  -    ./in.cue:187:10
   840  -    ./in.cue:188:5
   841       ./in.cue:189:5
   842   err.t8.V.c.e: field not allowed:
   843  -    ./in.cue:194:8
   844  -    ./in.cue:194:13
   845  -    ./in.cue:195:5
   846       ./in.cue:196:10
   847   ok.t13.x.c: field not allowed:
   848  -    ./in.cue:106:6
   849  -    ./in.cue:107:3
   850  -    ./in.cue:110:10
   851  -    ./in.cue:111:5
   852       ./in.cue:112:5
   853   ok.t5.x.c: field not allowed:
   854  -    ./in.cue:35:6
   855  -    ./in.cue:36:3
   856  -    ./in.cue:39:10
   857  -    ./in.cue:40:5
   858       ./in.cue:41:5
   859   validator.keepClosed.x.c: field not allowed:
   860  -    ./validators.cue:18:6
   861  -    ./validators.cue:23:5
   862       ./validators.cue:24:5
   863  -validator.open.data: invalid value {trailingComma:_|_(validator.open.data.trailingComma: field not allowed),#x:{trailingComma?:"all"}} (does not satisfy matchN): 0 matched, expected 1:
   864  -    ./validators.cue:10:3
   865  -    ./validators.cue:10:10
   866  -    ./validators.cue:13:8
   867  -    ./validators.cue:14:8
   868  -validator.open.data.trailingComma: field not allowed:
   869  -    ./validators.cue:10:3
   870  -    ./validators.cue:9:11
   871  -    ./validators.cue:13:8
   872  -    ./validators.cue:14:8
   873   
   874   Result:
   875   (_|_){
   876  @@ -77,7 +31,7 @@
   877       // [eval]
   878       t1: (struct){
   879         c: (#list){
   880  -        0: (struct){
   881  +        0: (#struct){
   882             b: (int){ int }
   883           }
   884         }
   885  @@ -86,7 +40,7 @@
   886       }
   887       t2: (struct){
   888         #A: (_){ _ }
   889  -      l: (struct){
   890  +      l: (#struct){
   891           f: (string){ "hi" }
   892         }
   893       }
   894  @@ -116,11 +70,11 @@
   895           }
   896         }
   897         W: (#struct){
   898  -        a: (#struct){
   899  -          b: (int){ 1 }
   900  -        }
   901  -        b: (struct){
   902  -          c: (int){ 2 }
   903  +        b: (struct){
   904  +          c: (int){ 2 }
   905  +        }
   906  +        a: (#struct){
   907  +          b: (int){ 1 }
   908           }
   909         }
   910       }
   911  @@ -134,10 +88,6 @@
   912           // [eval]
   913           c: (_|_){
   914             // [eval] ok.t5.x.c: field not allowed:
   915  -          //     ./in.cue:35:6
   916  -          //     ./in.cue:36:3
   917  -          //     ./in.cue:39:10
   918  -          //     ./in.cue:40:5
   919             //     ./in.cue:41:5
   920           }
   921         }
   922  @@ -170,16 +120,7 @@
   923         }
   924       }
   925       t8: (struct){
   926  -      foo: (#struct){
   927  -        a: (#struct){
   928  -          b: (#struct){
   929  -            c: (#struct){
   930  -              C: (int){ 1 }
   931  -              D: (int){ 2 }
   932  -            }
   933  -          }
   934  -        }
   935  -      }
   936  +      foo: ~(ok.t8.#X)
   937         #X: (#struct){
   938           a: (#struct){
   939             b: (#struct){
   940  @@ -193,7 +134,7 @@
   941       }
   942       t9: (struct){
   943         c: (#list){
   944  -        0: (struct){
   945  +        0: (#struct){
   946             b: (int){ int }
   947           }
   948         }
   949  @@ -202,7 +143,7 @@
   950       }
   951       t10: (struct){
   952         #A: (_){ _ }
   953  -      l: (struct){
   954  +      l: (#struct){
   955           f: (string){ "hi" }
   956         }
   957       }
   958  @@ -232,11 +173,11 @@
   959           }
   960         }
   961         W: (#struct){
   962  -        a: (#struct){
   963  -          b: (int){ 1 }
   964  -        }
   965  -        b: (struct){
   966  -          c: (int){ 2 }
   967  +        b: (struct){
   968  +          c: (int){ 2 }
   969  +        }
   970  +        a: (#struct){
   971  +          b: (int){ 1 }
   972           }
   973         }
   974       }
   975  @@ -250,10 +191,6 @@
   976           // [eval]
   977           c: (_|_){
   978             // [eval] ok.t13.x.c: field not allowed:
   979  -          //     ./in.cue:106:6
   980  -          //     ./in.cue:107:3
   981  -          //     ./in.cue:110:10
   982  -          //     ./in.cue:111:5
   983             //     ./in.cue:112:5
   984           }
   985         }
   986  @@ -277,13 +214,11 @@
   987         }
   988         a: (_|_){
   989           // [eval]
   990  -        a: (int){ 2 }
   991           disallowed: (_|_){
   992             // [eval] err.t1.a.disallowed: field not allowed:
   993  -          //     ./in.cue:133:10
   994  -          //     ./in.cue:134:5
   995             //     ./in.cue:135:5
   996           }
   997  +        a: (int){ 2 }
   998         }
   999       }
  1000       t2: (_|_){
  1001  @@ -297,14 +232,11 @@
  1002           // [eval]
  1003           c: (_|_){
  1004             // [eval]
  1005  -          d: (int){ 1 }
  1006             e: (_|_){
  1007               // [eval] err.t2.V.c.e: field not allowed:
  1008  -            //     ./in.cue:139:8
  1009  -            //     ./in.cue:139:13
  1010  -            //     ./in.cue:140:5
  1011               //     ./in.cue:141:10
  1012             }
  1013  +          d: (int){ 1 }
  1014           }
  1015         }
  1016       }
  1017  @@ -318,8 +250,6 @@
  1018             // [eval]
  1019             c: (_|_){
  1020               // [eval] err.t3.p1.a.c: field not allowed:
  1021  -            //     ./in.cue:145:6
  1022  -            //     ./in.cue:146:5
  1023               //     ./in.cue:147:5
  1024             }
  1025           }
  1026  @@ -336,8 +266,6 @@
  1027               // [eval]
  1028               c: (_|_){
  1029                 // [eval] err.t3.p2.a.b.c: field not allowed:
  1030  -              //     ./in.cue:151:9
  1031  -              //     ./in.cue:152:5
  1032                 //     ./in.cue:153:8
  1033               }
  1034             }
  1035  @@ -350,54 +278,47 @@
  1036           // [eval]
  1037           b: (_|_){
  1038             // [eval]
  1039  -          f: (int){ 1 }
  1040             h: (_|_){
  1041               // [eval] err.t4.a.b.h: field not allowed:
  1042  -            //     ./in.cue:157:5
  1043  -            //     ./in.cue:158:9
  1044               //     ./in.cue:159:8
  1045             }
  1046  -        }
  1047  -      }
  1048  -      #A: (#struct){
  1049  -        b: (#struct){
  1050  -          f: (int){ 1 }
  1051  -        }
  1052  -      }
  1053  -    }
  1054  -    t5: (_|_){
  1055  -      // [eval]
  1056  -      a: (#struct){
  1057  -        b: (#struct){
  1058  -          f: (int){ 1 }
  1059  -          g: (int){ 1 }
  1060  -        }
  1061  -      }
  1062  -      #A: (#struct){
  1063  -        b: (#struct){
  1064  -          f: (int){ 1 }
  1065  -        }
  1066  -      }
  1067  -      #B: (#struct){
  1068  -        b: (#struct){
  1069  -          g: (int){ 1 }
  1070  -        }
  1071  -      }
  1072  -      b: (_|_){
  1073  -        // [eval]
  1074  -        b: (_|_){
  1075  -          // [eval]
  1076  -          f: (int){ 1 }
  1077  -          g: (int){ 1 }
  1078  +          f: (int){ 1 }
  1079  +        }
  1080  +      }
  1081  +      #A: (#struct){
  1082  +        b: (#struct){
  1083  +          f: (int){ 1 }
  1084  +        }
  1085  +      }
  1086  +    }
  1087  +    t5: (_|_){
  1088  +      // [eval]
  1089  +      a: (#struct){
  1090  +        b: (#struct){
  1091  +          f: (int){ 1 }
  1092  +          g: (int){ 1 }
  1093  +        }
  1094  +      }
  1095  +      #A: (#struct){
  1096  +        b: (#struct){
  1097  +          f: (int){ 1 }
  1098  +        }
  1099  +      }
  1100  +      #B: (#struct){
  1101  +        b: (#struct){
  1102  +          g: (int){ 1 }
  1103  +        }
  1104  +      }
  1105  +      b: (_|_){
  1106  +        // [eval]
  1107  +        b: (_|_){
  1108  +          // [eval]
  1109             h: (_|_){
  1110               // [eval] err.t5.b.b.h: field not allowed:
  1111  -            //     ./in.cue:164:6
  1112  -            //     ./in.cue:164:10
  1113  -            //     ./in.cue:165:9
  1114  -            //     ./in.cue:166:9
  1115  -            //     ./in.cue:167:5
  1116               //     ./in.cue:168:8
  1117             }
  1118  +          f: (int){ 1 }
  1119  +          g: (int){ 1 }
  1120           }
  1121         }
  1122       }
  1123  @@ -447,17 +368,12 @@
  1124                 // [eval]
  1125                 e: (_|_){
  1126                   // [eval]
  1127  -                f: (int){ 1 }
  1128  -                g: (int){ 1 }
  1129                   h: (_|_){
  1130                     // [eval] err.t6.b.b.c.d.e.h: field not allowed:
  1131  -                  //     ./in.cue:173:6
  1132  -                  //     ./in.cue:173:10
  1133  -                  //     ./in.cue:174:18
  1134  -                  //     ./in.cue:175:18
  1135  -                  //     ./in.cue:176:5
  1136                     //     ./in.cue:177:17
  1137                   }
  1138  +                f: (int){ 1 }
  1139  +                g: (int){ 1 }
  1140                 }
  1141               }
  1142             }
  1143  @@ -471,13 +387,11 @@
  1144         }
  1145         a: (_|_){
  1146           // [eval]
  1147  -        a: (int){ 2 }
  1148           b: (_|_){
  1149             // [eval] err.t7.a.b: field not allowed:
  1150  -          //     ./in.cue:187:10
  1151  -          //     ./in.cue:188:5
  1152             //     ./in.cue:189:5
  1153           }
  1154  +        a: (int){ 2 }
  1155         }
  1156       }
  1157       t8: (_|_){
  1158  @@ -491,14 +405,11 @@
  1159           // [eval]
  1160           c: (_|_){
  1161             // [eval]
  1162  -          d: (int){ 1 }
  1163             e: (_|_){
  1164               // [eval] err.t8.V.c.e: field not allowed:
  1165  -            //     ./in.cue:194:8
  1166  -            //     ./in.cue:194:13
  1167  -            //     ./in.cue:195:5
  1168               //     ./in.cue:196:10
  1169             }
  1170  +          d: (int){ 1 }
  1171           }
  1172         }
  1173       }
  1174  @@ -512,11 +423,11 @@
  1175         }
  1176       }
  1177       egs: (struct){
  1178  -      x1: (struct){
  1179  +      x1: (#struct){
  1180           name: (string){ "blah" }
  1181           age1: (int){ 5 }
  1182         }
  1183  -      x2: (struct){
  1184  +      x2: (#struct){
  1185           name: (string){ "blah" }
  1186           age2: (int){ 5 }
  1187         }
  1188  @@ -540,8 +451,7 @@
  1189     }
  1190     validator: (_|_){
  1191       // [eval]
  1192  -    open: (_|_){
  1193  -      // [eval]
  1194  +    open: (struct){
  1195         #Schema: (_){
  1196           matchN(1, (#list){
  1197             0: (_|_){// 〈1;#x〉
  1198  @@ -551,28 +461,10 @@
  1199             trailingComma?: (string){ "all" }
  1200           }
  1201         }
  1202  -      data: (_|_){
  1203  -        // [eval] validator.open.data: invalid value {trailingComma:_|_(validator.open.data.trailingComma: field not allowed),#x:{trailingComma?:"all"}} (does not satisfy matchN): 0 matched, expected 1:
  1204  -        //     ./validators.cue:10:3
  1205  -        //     ./validators.cue:10:10
  1206  -        //     ./validators.cue:13:8
  1207  -        //     ./validators.cue:14:8
  1208  -        // validator.open.data.trailingComma: field not allowed:
  1209  -        //     ./validators.cue:10:3
  1210  -        //     ./validators.cue:9:11
  1211  -        //     ./validators.cue:13:8
  1212  -        //     ./validators.cue:14:8
  1213  -        trailingComma: (_|_){
  1214  -          // [eval] validator.open.data.trailingComma: field not allowed:
  1215  -          //     ./validators.cue:10:3
  1216  -          //     ./validators.cue:9:11
  1217  -          //     ./validators.cue:13:8
  1218  -          //     ./validators.cue:14:8
  1219  -        }
  1220  -        #x: (_|_){
  1221  -          // [eval]
  1222  -          trailingComma?: (_|_){// "all"
  1223  -          }
  1224  +      data: (#struct){
  1225  +        trailingComma: (string){ "all" }
  1226  +        #x: (#struct){
  1227  +          trailingComma?: (string){ "all" }
  1228           }
  1229         }
  1230       }
  1231  @@ -584,14 +476,12 @@
  1232         }
  1233         x: (_|_){
  1234           // [eval]
  1235  -        a?: (int){ int }
  1236  -        b?: (int){ int }
  1237           c: (_|_){
  1238             // [eval] validator.keepClosed.x.c: field not allowed:
  1239  -          //     ./validators.cue:18:6
  1240  -          //     ./validators.cue:23:5
  1241             //     ./validators.cue:24:5
  1242           }
  1243  +        a?: (int){ int }
  1244  +        b?: (int){ int }
  1245         }
  1246       }
  1247     }
  1248  -- diff/todo/p2 --
  1249  all: error positions and reordering.
  1250  -- diff/explanation --
  1251  issue1830: the new evaluator correctly rejects inserting new fields in a closed struct
  1252  err.t(1|2): bug fixes.
  1253  -- out/eval --
  1254  Errors:
  1255  err.t1.a.disallowed: field not allowed:
  1256      ./in.cue:133:10
  1257      ./in.cue:134:5
  1258      ./in.cue:135:5
  1259  err.t2.V.c.e: field not allowed:
  1260      ./in.cue:139:8
  1261      ./in.cue:139:13
  1262      ./in.cue:140:5
  1263      ./in.cue:141:10
  1264  err.t3.p1.a.c: field not allowed:
  1265      ./in.cue:145:6
  1266      ./in.cue:146:5
  1267      ./in.cue:147:5
  1268  err.t3.p2.a.b.c: field not allowed:
  1269      ./in.cue:151:9
  1270      ./in.cue:152:5
  1271      ./in.cue:153:8
  1272  err.t4.a.b.h: field not allowed:
  1273      ./in.cue:157:5
  1274      ./in.cue:158:9
  1275      ./in.cue:159:8
  1276  err.t5.b.b.h: field not allowed:
  1277      ./in.cue:164:6
  1278      ./in.cue:164:10
  1279      ./in.cue:165:9
  1280      ./in.cue:166:9
  1281      ./in.cue:167:5
  1282      ./in.cue:168:8
  1283  err.t6.b.b.c.d.e.h: field not allowed:
  1284      ./in.cue:173:6
  1285      ./in.cue:173:10
  1286      ./in.cue:174:18
  1287      ./in.cue:175:18
  1288      ./in.cue:176:5
  1289      ./in.cue:177:17
  1290  err.t7.a.b: field not allowed:
  1291      ./in.cue:187:10
  1292      ./in.cue:188:5
  1293      ./in.cue:189:5
  1294  err.t8.V.c.e: field not allowed:
  1295      ./in.cue:194:8
  1296      ./in.cue:194:13
  1297      ./in.cue:195:5
  1298      ./in.cue:196:10
  1299  ok.t13.x.c: field not allowed:
  1300      ./in.cue:106:6
  1301      ./in.cue:107:3
  1302      ./in.cue:110:10
  1303      ./in.cue:111:5
  1304      ./in.cue:112:5
  1305  ok.t5.x.c: field not allowed:
  1306      ./in.cue:35:6
  1307      ./in.cue:36:3
  1308      ./in.cue:39:10
  1309      ./in.cue:40:5
  1310      ./in.cue:41:5
  1311  validator.keepClosed.x.c: field not allowed:
  1312      ./validators.cue:18:6
  1313      ./validators.cue:23:5
  1314      ./validators.cue:24:5
  1315  validator.open.data: invalid value {trailingComma:_|_(validator.open.data.trailingComma: field not allowed),#x:{trailingComma?:"all"}} (does not satisfy matchN): 0 matched, expected 1:
  1316      ./validators.cue:10:3
  1317      ./validators.cue:10:10
  1318      ./validators.cue:13:8
  1319      ./validators.cue:14:8
  1320  validator.open.data.trailingComma: field not allowed:
  1321      ./validators.cue:10:3
  1322      ./validators.cue:9:11
  1323      ./validators.cue:13:8
  1324      ./validators.cue:14:8
  1325  
  1326  Result:
  1327  (_|_){
  1328    // [eval]
  1329    ok: (_|_){
  1330      // [eval]
  1331      t1: (struct){
  1332        c: (#list){
  1333          0: (struct){
  1334            b: (int){ int }
  1335          }
  1336        }
  1337        #R: (list){
  1338        }
  1339      }
  1340      t2: (struct){
  1341        #A: (_){ _ }
  1342        l: (struct){
  1343          f: (string){ "hi" }
  1344        }
  1345      }
  1346      t3: (struct){
  1347        #A: (#struct){
  1348          f: (#struct){
  1349          }
  1350        }
  1351        #A1: (#struct){
  1352          f: (#struct){
  1353          }
  1354        }
  1355        s: (struct){
  1356          foo: (#struct){
  1357            f: (#struct){
  1358              d: (struct){
  1359                foo: (int){ 1 }
  1360              }
  1361            }
  1362          }
  1363        }
  1364      }
  1365      t4: (struct){
  1366        #T: (#struct){
  1367          a: (#struct){
  1368            b: (int){ 1 }
  1369          }
  1370        }
  1371        W: (#struct){
  1372          a: (#struct){
  1373            b: (int){ 1 }
  1374          }
  1375          b: (struct){
  1376            c: (int){ 2 }
  1377          }
  1378        }
  1379      }
  1380      t5: (_|_){
  1381        // [eval]
  1382        #A: (#struct){
  1383        }
  1384        Common: (struct){
  1385        }
  1386        x: (_|_){
  1387          // [eval]
  1388          c: (_|_){
  1389            // [eval] ok.t5.x.c: field not allowed:
  1390            //     ./in.cue:35:6
  1391            //     ./in.cue:36:3
  1392            //     ./in.cue:39:10
  1393            //     ./in.cue:40:5
  1394            //     ./in.cue:41:5
  1395          }
  1396        }
  1397      }
  1398      t6: (struct){
  1399        #A: (#struct){
  1400        }
  1401        Common: (struct){
  1402        }
  1403        x: (#struct){
  1404          c: (int){ int }
  1405        }
  1406      }
  1407      t7: (struct){
  1408        a: (#struct){
  1409          b: (#struct){
  1410            f: (int){ 1 }
  1411            g: (int){ 1 }
  1412          }
  1413        }
  1414        #A: (#struct){
  1415          b: (#struct){
  1416            f: (int){ 1 }
  1417          }
  1418        }
  1419        #B: (#struct){
  1420          b: (#struct){
  1421            g: (int){ 1 }
  1422          }
  1423        }
  1424      }
  1425      t8: (struct){
  1426        foo: (#struct){
  1427          a: (#struct){
  1428            b: (#struct){
  1429              c: (#struct){
  1430                C: (int){ 1 }
  1431                D: (int){ 2 }
  1432              }
  1433            }
  1434          }
  1435        }
  1436        #X: (#struct){
  1437          a: (#struct){
  1438            b: (#struct){
  1439              c: (#struct){
  1440                C: (int){ 1 }
  1441                D: (int){ 2 }
  1442              }
  1443            }
  1444          }
  1445        }
  1446      }
  1447      t9: (struct){
  1448        c: (#list){
  1449          0: (struct){
  1450            b: (int){ int }
  1451          }
  1452        }
  1453        #R: (list){
  1454        }
  1455      }
  1456      t10: (struct){
  1457        #A: (_){ _ }
  1458        l: (struct){
  1459          f: (string){ "hi" }
  1460        }
  1461      }
  1462      t11: (struct){
  1463        #A: (#struct){
  1464          f: (#struct){
  1465          }
  1466        }
  1467        #A1: (#struct){
  1468          f: (#struct){
  1469          }
  1470        }
  1471        s: (struct){
  1472          foo: (#struct){
  1473            f: (#struct){
  1474              d: (struct){
  1475                foo: (string){ "bar" }
  1476              }
  1477            }
  1478          }
  1479        }
  1480      }
  1481      t12: (struct){
  1482        #T: (#struct){
  1483          a: (#struct){
  1484            b: (int){ 1 }
  1485          }
  1486        }
  1487        W: (#struct){
  1488          a: (#struct){
  1489            b: (int){ 1 }
  1490          }
  1491          b: (struct){
  1492            c: (int){ 2 }
  1493          }
  1494        }
  1495      }
  1496      t13: (_|_){
  1497        // [eval]
  1498        #A: (#struct){
  1499        }
  1500        Common: (struct){
  1501        }
  1502        x: (_|_){
  1503          // [eval]
  1504          c: (_|_){
  1505            // [eval] ok.t13.x.c: field not allowed:
  1506            //     ./in.cue:106:6
  1507            //     ./in.cue:107:3
  1508            //     ./in.cue:110:10
  1509            //     ./in.cue:111:5
  1510            //     ./in.cue:112:5
  1511          }
  1512        }
  1513      }
  1514      t14: (struct){
  1515        #A: (#struct){
  1516        }
  1517        Common: (struct){
  1518        }
  1519        x: (#struct){
  1520          c: (int){ int }
  1521        }
  1522      }
  1523    }
  1524    err: (_|_){
  1525      // [eval]
  1526      t1: (_|_){
  1527        // [eval]
  1528        #D: (#struct){
  1529          a: (int){ 2 }
  1530        }
  1531        a: (_|_){
  1532          // [eval]
  1533          a: (int){ 2 }
  1534          disallowed: (_|_){
  1535            // [eval] err.t1.a.disallowed: field not allowed:
  1536            //     ./in.cue:133:10
  1537            //     ./in.cue:134:5
  1538            //     ./in.cue:135:5
  1539          }
  1540        }
  1541      }
  1542      t2: (_|_){
  1543        // [eval]
  1544        #S: (#struct){
  1545          c: (#struct){
  1546            d: (int){ 1 }
  1547          }
  1548        }
  1549        V: (_|_){
  1550          // [eval]
  1551          c: (_|_){
  1552            // [eval]
  1553            d: (int){ 1 }
  1554            e: (_|_){
  1555              // [eval] err.t2.V.c.e: field not allowed:
  1556              //     ./in.cue:139:8
  1557              //     ./in.cue:139:13
  1558              //     ./in.cue:140:5
  1559              //     ./in.cue:141:10
  1560            }
  1561          }
  1562        }
  1563      }
  1564      t3: (_|_){
  1565        // [eval]
  1566        p1: (_|_){
  1567          // [eval]
  1568          #D: (#struct){
  1569          }
  1570          a: (_|_){
  1571            // [eval]
  1572            c: (_|_){
  1573              // [eval] err.t3.p1.a.c: field not allowed:
  1574              //     ./in.cue:145:6
  1575              //     ./in.cue:146:5
  1576              //     ./in.cue:147:5
  1577            }
  1578          }
  1579        }
  1580        p2: (_|_){
  1581          // [eval]
  1582          #D: (#struct){
  1583            b: (#struct){
  1584            }
  1585          }
  1586          a: (_|_){
  1587            // [eval]
  1588            b: (_|_){
  1589              // [eval]
  1590              c: (_|_){
  1591                // [eval] err.t3.p2.a.b.c: field not allowed:
  1592                //     ./in.cue:151:9
  1593                //     ./in.cue:152:5
  1594                //     ./in.cue:153:8
  1595              }
  1596            }
  1597          }
  1598        }
  1599      }
  1600      t4: (_|_){
  1601        // [eval]
  1602        a: (_|_){
  1603          // [eval]
  1604          b: (_|_){
  1605            // [eval]
  1606            f: (int){ 1 }
  1607            h: (_|_){
  1608              // [eval] err.t4.a.b.h: field not allowed:
  1609              //     ./in.cue:157:5
  1610              //     ./in.cue:158:9
  1611              //     ./in.cue:159:8
  1612            }
  1613          }
  1614        }
  1615        #A: (#struct){
  1616          b: (#struct){
  1617            f: (int){ 1 }
  1618          }
  1619        }
  1620      }
  1621      t5: (_|_){
  1622        // [eval]
  1623        a: (#struct){
  1624          b: (#struct){
  1625            f: (int){ 1 }
  1626            g: (int){ 1 }
  1627          }
  1628        }
  1629        #A: (#struct){
  1630          b: (#struct){
  1631            f: (int){ 1 }
  1632          }
  1633        }
  1634        #B: (#struct){
  1635          b: (#struct){
  1636            g: (int){ 1 }
  1637          }
  1638        }
  1639        b: (_|_){
  1640          // [eval]
  1641          b: (_|_){
  1642            // [eval]
  1643            f: (int){ 1 }
  1644            g: (int){ 1 }
  1645            h: (_|_){
  1646              // [eval] err.t5.b.b.h: field not allowed:
  1647              //     ./in.cue:164:6
  1648              //     ./in.cue:164:10
  1649              //     ./in.cue:165:9
  1650              //     ./in.cue:166:9
  1651              //     ./in.cue:167:5
  1652              //     ./in.cue:168:8
  1653            }
  1654          }
  1655        }
  1656      }
  1657      t6: (_|_){
  1658        // [eval]
  1659        a: (#struct){
  1660          b: (#struct){
  1661            c: (#struct){
  1662              d: (#struct){
  1663                e: (#struct){
  1664                  f: (int){ 1 }
  1665                  g: (int){ 1 }
  1666                }
  1667              }
  1668            }
  1669          }
  1670        }
  1671        #A: (#struct){
  1672          b: (#struct){
  1673            c: (#struct){
  1674              d: (#struct){
  1675                e: (#struct){
  1676                  f: (int){ 1 }
  1677                }
  1678              }
  1679            }
  1680          }
  1681        }
  1682        #B: (#struct){
  1683          b: (#struct){
  1684            c: (#struct){
  1685              d: (#struct){
  1686                e: (#struct){
  1687                  g: (int){ 1 }
  1688                }
  1689              }
  1690            }
  1691          }
  1692        }
  1693        b: (_|_){
  1694          // [eval]
  1695          b: (_|_){
  1696            // [eval]
  1697            c: (_|_){
  1698              // [eval]
  1699              d: (_|_){
  1700                // [eval]
  1701                e: (_|_){
  1702                  // [eval]
  1703                  f: (int){ 1 }
  1704                  g: (int){ 1 }
  1705                  h: (_|_){
  1706                    // [eval] err.t6.b.b.c.d.e.h: field not allowed:
  1707                    //     ./in.cue:173:6
  1708                    //     ./in.cue:173:10
  1709                    //     ./in.cue:174:18
  1710                    //     ./in.cue:175:18
  1711                    //     ./in.cue:176:5
  1712                    //     ./in.cue:177:17
  1713                  }
  1714                }
  1715              }
  1716            }
  1717          }
  1718        }
  1719      }
  1720      t7: (_|_){
  1721        // [eval]
  1722        #D: (#struct){
  1723          a: (int){ 2 }
  1724        }
  1725        a: (_|_){
  1726          // [eval]
  1727          a: (int){ 2 }
  1728          b: (_|_){
  1729            // [eval] err.t7.a.b: field not allowed:
  1730            //     ./in.cue:187:10
  1731            //     ./in.cue:188:5
  1732            //     ./in.cue:189:5
  1733          }
  1734        }
  1735      }
  1736      t8: (_|_){
  1737        // [eval]
  1738        #S: (#struct){
  1739          c: (#struct){
  1740            d: (int){ 1 }
  1741          }
  1742        }
  1743        V: (_|_){
  1744          // [eval]
  1745          c: (_|_){
  1746            // [eval]
  1747            d: (int){ 1 }
  1748            e: (_|_){
  1749              // [eval] err.t8.V.c.e: field not allowed:
  1750              //     ./in.cue:194:8
  1751              //     ./in.cue:194:13
  1752              //     ./in.cue:195:5
  1753              //     ./in.cue:196:10
  1754            }
  1755          }
  1756        }
  1757      }
  1758    }
  1759    issue1830: (struct){
  1760      #x: (#struct){
  1761        y: (#struct){
  1762          z?: (#struct){
  1763            name: (string){ string }
  1764          }
  1765        }
  1766      }
  1767      egs: (struct){
  1768        x1: (struct){
  1769          name: (string){ "blah" }
  1770          age1: (int){ 5 }
  1771        }
  1772        x2: (struct){
  1773          name: (string){ "blah" }
  1774          age2: (int){ 5 }
  1775        }
  1776      }
  1777    }
  1778    issue3491: (struct){
  1779      #Schema: (#struct){
  1780        field?: (#struct){
  1781        }
  1782      }
  1783      a: (#struct){
  1784        field: (#struct){
  1785        }
  1786        #Extra: (#struct){
  1787        }
  1788      }
  1789      b: (struct){
  1790        #Extra: (#struct){
  1791        }
  1792      }
  1793    }
  1794    validator: (_|_){
  1795      // [eval]
  1796      open: (_|_){
  1797        // [eval]
  1798        #Schema: (_){
  1799          matchN(1, (#list){
  1800            0: (_|_){// 〈1;#x〉
  1801            }
  1802          })
  1803          #x: (#struct){
  1804            trailingComma?: (string){ "all" }
  1805          }
  1806        }
  1807        data: (_|_){
  1808          // [eval] validator.open.data: invalid value {trailingComma:_|_(validator.open.data.trailingComma: field not allowed),#x:{trailingComma?:"all"}} (does not satisfy matchN): 0 matched, expected 1:
  1809          //     ./validators.cue:10:3
  1810          //     ./validators.cue:10:10
  1811          //     ./validators.cue:13:8
  1812          //     ./validators.cue:14:8
  1813          // validator.open.data.trailingComma: field not allowed:
  1814          //     ./validators.cue:10:3
  1815          //     ./validators.cue:9:11
  1816          //     ./validators.cue:13:8
  1817          //     ./validators.cue:14:8
  1818          trailingComma: (_|_){
  1819            // [eval] validator.open.data.trailingComma: field not allowed:
  1820            //     ./validators.cue:10:3
  1821            //     ./validators.cue:9:11
  1822            //     ./validators.cue:13:8
  1823            //     ./validators.cue:14:8
  1824          }
  1825          #x: (_|_){
  1826            // [eval]
  1827            trailingComma?: (_|_){// "all"
  1828            }
  1829          }
  1830        }
  1831      }
  1832      keepClosed: (_|_){
  1833        // [eval]
  1834        #X: (#struct){
  1835          a?: (int){ int }
  1836          b?: (int){ int }
  1837        }
  1838        x: (_|_){
  1839          // [eval]
  1840          a?: (int){ int }
  1841          b?: (int){ int }
  1842          c: (_|_){
  1843            // [eval] validator.keepClosed.x.c: field not allowed:
  1844            //     ./validators.cue:18:6
  1845            //     ./validators.cue:23:5
  1846            //     ./validators.cue:24:5
  1847          }
  1848        }
  1849      }
  1850    }
  1851  }
  1852  -- out/compile --
  1853  --- in.cue
  1854  {
  1855    ok: {
  1856      t1: {
  1857        c: 〈0;#R〉
  1858        c: [
  1859          {
  1860            b: int
  1861          },
  1862        ]
  1863        #R: [
  1864          ...,
  1865        ]
  1866      }
  1867    }
  1868    ok: {
  1869      t2: {
  1870        #A: _
  1871        l: 〈0;#A〉
  1872        l: {
  1873          f: "hi"
  1874        }
  1875      }
  1876    }
  1877    ok: {
  1878      t3: {
  1879        #A: {
  1880          f: {
  1881            ...
  1882          }
  1883        }
  1884        #A1: {
  1885          〈1;#A〉
  1886        }
  1887        s: {
  1888          [string]: 〈1;#A1〉
  1889        }
  1890        s: {
  1891          foo: {
  1892            f: {
  1893              d: {
  1894                foo: 1
  1895              }
  1896            }
  1897          }
  1898        }
  1899      }
  1900    }
  1901    ok: {
  1902      t4: {
  1903        #T: {
  1904          a: {
  1905            b: 1
  1906          }
  1907        }
  1908        W: {
  1909          {
  1910            〈2;#T〉
  1911          }
  1912          b: {
  1913            c: 2
  1914          }
  1915        }
  1916      }
  1917    }
  1918    ok: {
  1919      t5: {
  1920        #A: {
  1921          〈1;Common〉
  1922          _
  1923        }
  1924        Common: {}
  1925        x: 〈0;#A〉
  1926        x: {
  1927          c: int
  1928        }
  1929      }
  1930    }
  1931    ok: {
  1932      t6: {
  1933        #A: {
  1934          〈1;Common〉
  1935          ...
  1936        }
  1937        Common: {}
  1938        x: 〈0;#A〉
  1939        x: {
  1940          c: int
  1941        }
  1942      }
  1943    }
  1944    ok: {
  1945      t7: {
  1946        a: {
  1947          〈1;#A〉
  1948          〈1;#B〉
  1949        }
  1950        #A: {
  1951          b: {
  1952            f: 1
  1953          }
  1954        }
  1955        #B: {
  1956          b: {
  1957            g: 1
  1958          }
  1959        }
  1960      }
  1961    }
  1962    ok: {
  1963      t8: {
  1964        foo: 〈0;#X〉
  1965        #X: {
  1966          a: {
  1967            b: {
  1968              c: {
  1969                C: 1
  1970              }
  1971            }
  1972          }
  1973          for k, _ in 〈0;a〉 {
  1974            a: {
  1975              〈2;k〉: {
  1976                c: {
  1977                  D: 2
  1978                }
  1979              }
  1980            }
  1981          }
  1982        }
  1983      }
  1984    }
  1985    ok: {
  1986      t9: {
  1987        c: 〈0;#R〉
  1988        c: [
  1989          {
  1990            b: int
  1991          },
  1992        ]
  1993        #R: [
  1994          ...,
  1995        ]
  1996      }
  1997    }
  1998    ok: {
  1999      t10: {
  2000        #A: _
  2001        l: 〈0;#A〉
  2002        l: {
  2003          f: "hi"
  2004        }
  2005      }
  2006    }
  2007    ok: {
  2008      t11: {
  2009        #A: {
  2010          f: {
  2011            ...
  2012          }
  2013        }
  2014        #A1: {
  2015          〈1;#A〉
  2016        }
  2017        s: {
  2018          [string]: 〈1;#A1〉
  2019        }
  2020        s: {
  2021          foo: {
  2022            f: {
  2023              d: {
  2024                foo: "bar"
  2025              }
  2026            }
  2027          }
  2028        }
  2029      }
  2030    }
  2031    ok: {
  2032      t12: {
  2033        #T: {
  2034          a: {
  2035            b: 1
  2036          }
  2037        }
  2038        W: {
  2039          {
  2040            〈2;#T〉
  2041          }
  2042          b: {
  2043            c: 2
  2044          }
  2045        }
  2046      }
  2047    }
  2048    ok: {
  2049      t13: {
  2050        #A: {
  2051          〈1;Common〉
  2052          _
  2053        }
  2054        Common: {}
  2055        x: 〈0;#A〉
  2056        x: {
  2057          c: int
  2058        }
  2059      }
  2060    }
  2061    ok: {
  2062      t14: {
  2063        #A: {
  2064          〈1;Common〉
  2065          ...
  2066        }
  2067        Common: {}
  2068        x: 〈0;#A〉
  2069        x: {
  2070          c: int
  2071        }
  2072      }
  2073    }
  2074    err: {
  2075      t1: {
  2076        #D: (_ & {
  2077          a: 2
  2078        })
  2079        a: 〈0;#D〉
  2080        a: {
  2081          disallowed: 1
  2082        }
  2083      }
  2084    }
  2085    err: {
  2086      t2: {
  2087        #S: {
  2088          {
  2089            c: {
  2090              d: 1
  2091            }
  2092          }
  2093        }
  2094        V: 〈0;#S〉
  2095        V: {
  2096          c: {
  2097            e: 1
  2098          }
  2099        }
  2100      }
  2101    }
  2102    err: {
  2103      t3: {
  2104        p1: {
  2105          #D: {}
  2106          a: 〈0;#D〉
  2107          a: {
  2108            c: "C"
  2109          }
  2110        }
  2111      }
  2112    }
  2113    err: {
  2114      t3: {
  2115        p2: {
  2116          #D: {
  2117            b: {}
  2118          }
  2119          a: 〈0;#D〉
  2120          a: {
  2121            b: {
  2122              c: "C"
  2123            }
  2124          }
  2125        }
  2126      }
  2127    }
  2128    err: {
  2129      t4: {
  2130        a: 〈0;#A〉
  2131        #A: {
  2132          b: {
  2133            f: 1
  2134          }
  2135        }
  2136        a: {
  2137          b: {
  2138            h: 1
  2139          }
  2140        }
  2141      }
  2142    }
  2143    err: {
  2144      t5: {
  2145        a: {
  2146          〈1;#A〉
  2147          〈1;#B〉
  2148        }
  2149        #A: {
  2150          b: {
  2151            f: 1
  2152          }
  2153        }
  2154        #B: {
  2155          b: {
  2156            g: 1
  2157          }
  2158        }
  2159        b: 〈0;a〉
  2160        b: {
  2161          b: {
  2162            h: 1
  2163          }
  2164        }
  2165      }
  2166    }
  2167    err: {
  2168      t6: {
  2169        a: {
  2170          〈1;#A〉
  2171          〈1;#B〉
  2172        }
  2173        #A: {
  2174          b: {
  2175            c: {
  2176              d: {
  2177                e: {
  2178                  f: 1
  2179                }
  2180              }
  2181            }
  2182          }
  2183        }
  2184        #B: {
  2185          b: {
  2186            c: {
  2187              d: {
  2188                e: {
  2189                  g: 1
  2190                }
  2191              }
  2192            }
  2193          }
  2194        }
  2195        b: 〈0;a〉
  2196        b: {
  2197          b: {
  2198            c: {
  2199              d: {
  2200                e: {
  2201                  h: 1
  2202                }
  2203              }
  2204            }
  2205          }
  2206        }
  2207      }
  2208    }
  2209    err: {
  2210      t7: {
  2211        #D: (_ & {
  2212          a: 2
  2213        })
  2214        a: 〈0;#D〉
  2215        a: {
  2216          b: 1
  2217        }
  2218      }
  2219    }
  2220    err: {
  2221      t8: {
  2222        #S: {
  2223          {
  2224            c: {
  2225              d: 1
  2226            }
  2227          }
  2228        }
  2229        V: 〈0;#S〉
  2230        V: {
  2231          c: {
  2232            e: 1
  2233          }
  2234        }
  2235      }
  2236    }
  2237  }
  2238  --- issue1830.cue
  2239  {
  2240    issue1830: {
  2241      #x: {
  2242        y: {
  2243          z?: {
  2244            name: string
  2245          }
  2246        }
  2247      }
  2248      egs: {
  2249        x1: ((〈1;#x〉 & {
  2250          y: {
  2251            z: _
  2252          }
  2253        }).y.z & {
  2254          name: "blah"
  2255          age1: 5
  2256        })
  2257        x2: ((〈1;#x〉.y & {
  2258          z: _
  2259        }).z & {
  2260          name: "blah"
  2261          age2: 5
  2262        })
  2263      }
  2264    }
  2265  }
  2266  --- issue3491.cue
  2267  {
  2268    issue3491: {
  2269      #Schema: {
  2270        field?: {}
  2271      }
  2272      a: (〈0;#Schema〉 & {
  2273        field: {}
  2274      })
  2275      a: 〈0;b〉
  2276      b: {
  2277        #Extra: {}
  2278      }
  2279    }
  2280  }
  2281  --- validators.cue
  2282  {
  2283    validator: {
  2284      open: {
  2285        #Schema: {
  2286          matchN(1, [
  2287            〈1;#x〉,
  2288          ])
  2289          #x: {
  2290            trailingComma?: "all"
  2291          }
  2292        }
  2293        data: {
  2294          trailingComma: "all"
  2295        }
  2296        data: 〈0;#Schema〉
  2297      }
  2298    }
  2299    validator: {
  2300      keepClosed: {
  2301        #X: {
  2302          〈import;struct〉.MaxFields(1)
  2303          a?: int
  2304          b?: int
  2305        }
  2306        x: 〈0;#X〉
  2307        x: {
  2308          c: 1
  2309        }
  2310      }
  2311    }
  2312  }