...

Text file src/cuelang.org/go/cue/testdata/definitions/fields.txtar

Documentation: cuelang.org/go/cue/testdata/definitions

     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
     9ok: t1: {
    10	c: #R
    11	c: [{b: int}]
    12	#R: [...]
    13}
    14
    15ok: t2: {
    16	#A: _
    17	l: #A
    18	l: f: "hi"
    19}
    20
    21ok: t3: {
    22	#A: f: {...}
    23	#A1: { #A }
    24	s: [string]: #A1
    25	s: foo: f: d: foo: 1
    26}
    27
    28ok: t4: {
    29	#T: { a: b: 1 }
    30	W: {
    31		{#T}
    32		b: c: 2
    33	}
    34}
    35
    36ok: t5: {
    37	// TODO: this should pass
    38	#A: {
    39		Common
    40		_
    41	}
    42	Common: { }
    43	x: #A
    44	x: c: int
    45}
    46
    47ok: t6: {
    48	#A: {
    49		Common
    50		...
    51	}
    52	Common: { }
    53	x: #A
    54	x: c: int
    55}
    56
    57ok: t7: {
    58	a: {#A, #B}
    59	#A: b: f: 1
    60	#B: b: g: 1
    61}
    62
    63ok: 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
    76ok: t9: {
    77	c: #R
    78	c: [{b: int}]
    79	#R: [...]
    80}
    81
    82ok: t10: {
    83	#A: _ // top should allow everything
    84	l: #A
    85	l: f: "hi"
    86}
    87
    88ok: t11: {
    89	// indirections
    90	#A: f: {...}
    91	#A1: { #A }
    92	s: [string]: #A1
    93	s: foo: f: d: foo: "bar" // should pass
    94}
    95
    96ok: t12: {
    97	// nested embedding
    98	#T: { a: b: 1 }
    99	W: {
   100		{#T}
   101		b: c: 2
   102	}
   103}
   104
   105ok: t13: {
   106	// TODO: this should pass
   107
   108	// top opens up
   109	#A: {
   110		Common
   111		_
   112	}
   113	Common: { }
   114	x: #A
   115	x: c: int
   116}
   117
   118ok: t14: {
   119	// ellipsis opens up
   120	#A: {
   121		Common
   122		...
   123	}
   124	Common: { }
   125	x: #A
   126	x: c: int
   127}
   128
   129
   130err: t1: {
   131	#D: _ & {a: 2}
   132	a: #D
   133	a: disallowed: 1
   134}
   135
   136err: t2: {
   137	#S: { { c: d: 1 } }
   138	V: #S
   139	V: { c: e:  1 }
   140}
   141
   142err: t3: p1: {
   143	#D: {}
   144	a: #D
   145	a: c: "C"
   146}
   147
   148err: t3: p2: {
   149	#D: b: {}
   150	a: #D
   151	a: b: c: "C"
   152}
   153
   154err: t4: {
   155	a: #A
   156	#A: b: f: 1
   157	a: b: h: 1
   158}
   159
   160err: t5: {
   161	// TODO: this should fail
   162	a: {#A, #B}
   163	#A: b: f: 1
   164	#B: b: g: 1
   165	b: a
   166	b: b: h: 1 // only an error here
   167}
   168
   169err: t6: {
   170	// TODO: this should fail
   171	a: {#A, #B}
   172	#A: b: c: d: e: f: 1
   173	#B: b: c: d: e: g: 1
   174	b: a
   175	b: b: c: d: e: h: 1 // only an error here
   176}
   177
   178err: t7: {
   179	#D: _ & {a: 2}
   180	a: #D
   181	a: b: 1 // FAIL
   182}
   183
   184err: t8: {
   185	// nested embedding
   186	#S: { { c: d: 1 } }
   187	V: #S
   188	V: { c: e:  1 } // Should fail
   189}
   190-- diff/explanation --
   191ok.t5 and ok.t13 retain semantics of v0.6 for now.
   192-- out/eval/stats --
   193Leaks:  0
   194Freed:  194
   195Reused: 184
   196Allocs: 10
   197Retain: 14
   198
   199Unifications: 194
   200Conjuncts:    353
   201Disjuncts:    208
   202-- out/evalalpha --
   203Errors:
   204err.t2.V.c.e: field not allowed:
   205    ./in.cue:136:10
   206err.t3.p2.a.b.c: field not allowed:
   207    ./in.cue:148:8
   208err.t4.a.b.h: field not allowed:
   209    ./in.cue:154:8
   210err.t5.b.b.h: field not allowed:
   211    ./in.cue:163:8
   212err.t6.b.b.c.d.e.h: field not allowed:
   213    ./in.cue:172:17
   214err.t8.V.c.e: field not allowed:
   215    ./in.cue:185:10
   216ok.t5.x.c: field not allowed:
   217    ./in.cue:36:3
   218    ./in.cue:41:5
   219ok.t13.x.c: field not allowed:
   220    ./in.cue:107:3
   221    ./in.cue:112:5
   222err.t1.a.disallowed: field not allowed:
   223    ./in.cue:129:5
   224    ./in.cue:130:5
   225err.t3.p1.a.c: field not allowed:
   226    ./in.cue:141:5
   227    ./in.cue:142:5
   228err.t7.a.b: field not allowed:
   229    ./in.cue:177:5
   230    ./in.cue:178:5
   231
   232Result:
   233(_|_){
   234  // [eval]
   235  ok: (_|_){
   236    // [eval]
   237    t1: (struct){
   238      c: (#list){
   239        0: (#struct){
   240          b: (int){ int }
   241        }
   242      }
   243      #R: (list){
   244      }
   245    }
   246    t2: (struct){
   247      #A: (_){ _ }
   248      l: (#struct){
   249        f: (string){ "hi" }
   250      }
   251    }
   252    t3: (struct){
   253      #A: (#struct){
   254        f: (#struct){
   255        }
   256      }
   257      #A1: (#struct){
   258        f: (#struct){
   259        }
   260      }
   261      s: (struct){
   262        foo: (#struct){
   263          f: (#struct){
   264            d: (#struct){
   265              foo: (int){ 1 }
   266            }
   267          }
   268        }
   269      }
   270    }
   271    t4: (struct){
   272      #T: (#struct){
   273        a: (#struct){
   274          b: (int){ 1 }
   275        }
   276      }
   277      W: (#struct){
   278        b: (#struct){
   279          c: (int){ 2 }
   280        }
   281        a: (#struct){
   282          b: (int){ 1 }
   283        }
   284      }
   285    }
   286    t5: (_|_){
   287      // [eval]
   288      #A: (#struct){
   289      }
   290      Common: (struct){
   291      }
   292      x: (_|_){
   293        // [eval]
   294        c: (_|_){
   295          // [eval] ok.t5.x.c: field not allowed:
   296          //     ./in.cue:36:3
   297          //     ./in.cue:41:5
   298        }
   299      }
   300    }
   301    t6: (struct){
   302      #A: (#struct){
   303      }
   304      Common: (struct){
   305      }
   306      x: (#struct){
   307        c: (int){ int }
   308      }
   309    }
   310    t7: (struct){
   311      a: (#struct){
   312        b: (#struct){
   313          f: (int){ 1 }
   314          g: (int){ 1 }
   315        }
   316      }
   317      #A: (#struct){
   318        b: (#struct){
   319          f: (int){ 1 }
   320        }
   321      }
   322      #B: (#struct){
   323        b: (#struct){
   324          g: (int){ 1 }
   325        }
   326      }
   327    }
   328    t8: (struct){
   329      foo: (#struct){
   330        a: (#struct){
   331          b: (#struct){
   332            c: (#struct){
   333              C: (int){ 1 }
   334              D: (int){ 2 }
   335            }
   336          }
   337        }
   338      }
   339      #X: (#struct){
   340        a: (#struct){
   341          b: (#struct){
   342            c: (#struct){
   343              C: (int){ 1 }
   344              D: (int){ 2 }
   345            }
   346          }
   347        }
   348      }
   349    }
   350    t9: (struct){
   351      c: (#list){
   352        0: (#struct){
   353          b: (int){ int }
   354        }
   355      }
   356      #R: (list){
   357      }
   358    }
   359    t10: (struct){
   360      #A: (_){ _ }
   361      l: (#struct){
   362        f: (string){ "hi" }
   363      }
   364    }
   365    t11: (struct){
   366      #A: (#struct){
   367        f: (#struct){
   368        }
   369      }
   370      #A1: (#struct){
   371        f: (#struct){
   372        }
   373      }
   374      s: (struct){
   375        foo: (#struct){
   376          f: (#struct){
   377            d: (#struct){
   378              foo: (string){ "bar" }
   379            }
   380          }
   381        }
   382      }
   383    }
   384    t12: (struct){
   385      #T: (#struct){
   386        a: (#struct){
   387          b: (int){ 1 }
   388        }
   389      }
   390      W: (#struct){
   391        b: (#struct){
   392          c: (int){ 2 }
   393        }
   394        a: (#struct){
   395          b: (int){ 1 }
   396        }
   397      }
   398    }
   399    t13: (_|_){
   400      // [eval]
   401      #A: (#struct){
   402      }
   403      Common: (struct){
   404      }
   405      x: (_|_){
   406        // [eval]
   407        c: (_|_){
   408          // [eval] ok.t13.x.c: field not allowed:
   409          //     ./in.cue:107:3
   410          //     ./in.cue:112:5
   411        }
   412      }
   413    }
   414    t14: (struct){
   415      #A: (#struct){
   416      }
   417      Common: (struct){
   418      }
   419      x: (#struct){
   420        c: (int){ int }
   421      }
   422    }
   423  }
   424  err: (_|_){
   425    // [eval]
   426    t1: (_|_){
   427      // [eval]
   428      #D: (#struct){
   429        a: (int){ 2 }
   430      }
   431      a: (_|_){
   432        // [eval]
   433        disallowed: (_|_){
   434          // [eval] err.t1.a.disallowed: field not allowed:
   435          //     ./in.cue:129:5
   436          //     ./in.cue:130:5
   437        }
   438        a: (int){ 2 }
   439      }
   440    }
   441    t2: (_|_){
   442      // [eval]
   443      #S: (#struct){
   444        c: (#struct){
   445          d: (int){ 1 }
   446        }
   447      }
   448      V: (_|_){
   449        // [eval]
   450        c: (_|_){
   451          // [eval]
   452          e: (_|_){
   453            // [eval] err.t2.V.c.e: field not allowed:
   454            //     ./in.cue:136:10
   455          }
   456          d: (int){ 1 }
   457        }
   458      }
   459    }
   460    t3: (_|_){
   461      // [eval]
   462      p1: (_|_){
   463        // [eval]
   464        #D: (#struct){
   465        }
   466        a: (_|_){
   467          // [eval]
   468          c: (_|_){
   469            // [eval] err.t3.p1.a.c: field not allowed:
   470            //     ./in.cue:141:5
   471            //     ./in.cue:142:5
   472          }
   473        }
   474      }
   475      p2: (_|_){
   476        // [eval]
   477        #D: (#struct){
   478          b: (#struct){
   479          }
   480        }
   481        a: (_|_){
   482          // [eval]
   483          b: (_|_){
   484            // [eval]
   485            c: (_|_){
   486              // [eval] err.t3.p2.a.b.c: field not allowed:
   487              //     ./in.cue:148:8
   488            }
   489          }
   490        }
   491      }
   492    }
   493    t4: (_|_){
   494      // [eval]
   495      a: (_|_){
   496        // [eval]
   497        b: (_|_){
   498          // [eval]
   499          h: (_|_){
   500            // [eval] err.t4.a.b.h: field not allowed:
   501            //     ./in.cue:154:8
   502          }
   503          f: (int){ 1 }
   504        }
   505      }
   506      #A: (#struct){
   507        b: (#struct){
   508          f: (int){ 1 }
   509        }
   510      }
   511    }
   512    t5: (_|_){
   513      // [eval]
   514      a: (#struct){
   515        b: (#struct){
   516          f: (int){ 1 }
   517          g: (int){ 1 }
   518        }
   519      }
   520      #A: (#struct){
   521        b: (#struct){
   522          f: (int){ 1 }
   523        }
   524      }
   525      #B: (#struct){
   526        b: (#struct){
   527          g: (int){ 1 }
   528        }
   529      }
   530      b: (_|_){
   531        // [eval]
   532        b: (_|_){
   533          // [eval]
   534          h: (_|_){
   535            // [eval] err.t5.b.b.h: field not allowed:
   536            //     ./in.cue:163:8
   537          }
   538          f: (int){ 1 }
   539          g: (int){ 1 }
   540        }
   541      }
   542    }
   543    t6: (_|_){
   544      // [eval]
   545      a: (#struct){
   546        b: (#struct){
   547          c: (#struct){
   548            d: (#struct){
   549              e: (#struct){
   550                f: (int){ 1 }
   551                g: (int){ 1 }
   552              }
   553            }
   554          }
   555        }
   556      }
   557      #A: (#struct){
   558        b: (#struct){
   559          c: (#struct){
   560            d: (#struct){
   561              e: (#struct){
   562                f: (int){ 1 }
   563              }
   564            }
   565          }
   566        }
   567      }
   568      #B: (#struct){
   569        b: (#struct){
   570          c: (#struct){
   571            d: (#struct){
   572              e: (#struct){
   573                g: (int){ 1 }
   574              }
   575            }
   576          }
   577        }
   578      }
   579      b: (_|_){
   580        // [eval]
   581        b: (_|_){
   582          // [eval]
   583          c: (_|_){
   584            // [eval]
   585            d: (_|_){
   586              // [eval]
   587              e: (_|_){
   588                // [eval]
   589                h: (_|_){
   590                  // [eval] err.t6.b.b.c.d.e.h: field not allowed:
   591                  //     ./in.cue:172:17
   592                }
   593                f: (int){ 1 }
   594                g: (int){ 1 }
   595              }
   596            }
   597          }
   598        }
   599      }
   600    }
   601    t7: (_|_){
   602      // [eval]
   603      #D: (#struct){
   604        a: (int){ 2 }
   605      }
   606      a: (_|_){
   607        // [eval]
   608        b: (_|_){
   609          // [eval] err.t7.a.b: field not allowed:
   610          //     ./in.cue:177:5
   611          //     ./in.cue:178:5
   612        }
   613        a: (int){ 2 }
   614      }
   615    }
   616    t8: (_|_){
   617      // [eval]
   618      #S: (#struct){
   619        c: (#struct){
   620          d: (int){ 1 }
   621        }
   622      }
   623      V: (_|_){
   624        // [eval]
   625        c: (_|_){
   626          // [eval]
   627          e: (_|_){
   628            // [eval] err.t8.V.c.e: field not allowed:
   629            //     ./in.cue:185:10
   630          }
   631          d: (int){ 1 }
   632        }
   633      }
   634    }
   635  }
   636}
   637-- diff/-out/evalalpha<==>+out/eval --
   638diff old new
   639--- old
   640+++ new
   641@@ -1,60 +1,31 @@
   642 Errors:
   643-err.t1.a.disallowed: field not allowed:
   644-    ./in.cue:128:10
   645-    ./in.cue:129:5
   646-    ./in.cue:130:5
   647 err.t2.V.c.e: field not allowed:
   648-    ./in.cue:134:8
   649-    ./in.cue:134:13
   650-    ./in.cue:135:5
   651     ./in.cue:136:10
   652-err.t3.p1.a.c: field not allowed:
   653-    ./in.cue:140:6
   654-    ./in.cue:141:5
   655-    ./in.cue:142:5
   656 err.t3.p2.a.b.c: field not allowed:
   657-    ./in.cue:146:9
   658-    ./in.cue:147:5
   659     ./in.cue:148:8
   660 err.t4.a.b.h: field not allowed:
   661-    ./in.cue:152:5
   662-    ./in.cue:153:9
   663     ./in.cue:154:8
   664 err.t5.b.b.h: field not allowed:
   665-    ./in.cue:159:6
   666-    ./in.cue:159:10
   667-    ./in.cue:160:9
   668-    ./in.cue:161:9
   669-    ./in.cue:162:5
   670     ./in.cue:163:8
   671 err.t6.b.b.c.d.e.h: field not allowed:
   672-    ./in.cue:168:6
   673-    ./in.cue:168:10
   674-    ./in.cue:169:18
   675-    ./in.cue:170:18
   676-    ./in.cue:171:5
   677     ./in.cue:172:17
   678-err.t7.a.b: field not allowed:
   679-    ./in.cue:176:10
   680-    ./in.cue:177:5
   681-    ./in.cue:178:5
   682 err.t8.V.c.e: field not allowed:
   683-    ./in.cue:183:8
   684-    ./in.cue:183:13
   685-    ./in.cue:184:5
   686     ./in.cue:185:10
   687-ok.t13.x.c: field not allowed:
   688-    ./in.cue:106:6
   689-    ./in.cue:107:3
   690-    ./in.cue:110:10
   691-    ./in.cue:111:5
   692-    ./in.cue:112:5
   693 ok.t5.x.c: field not allowed:
   694-    ./in.cue:35:6
   695     ./in.cue:36:3
   696-    ./in.cue:39:10
   697-    ./in.cue:40:5
   698     ./in.cue:41:5
   699+ok.t13.x.c: field not allowed:
   700+    ./in.cue:107:3
   701+    ./in.cue:112:5
   702+err.t1.a.disallowed: field not allowed:
   703+    ./in.cue:129:5
   704+    ./in.cue:130:5
   705+err.t3.p1.a.c: field not allowed:
   706+    ./in.cue:141:5
   707+    ./in.cue:142:5
   708+err.t7.a.b: field not allowed:
   709+    ./in.cue:177:5
   710+    ./in.cue:178:5
   711 
   712 Result:
   713 (_|_){
   714@@ -63,7 +34,7 @@
   715     // [eval]
   716     t1: (struct){
   717       c: (#list){
   718-        0: (struct){
   719+        0: (#struct){
   720           b: (int){ int }
   721         }
   722       }
   723@@ -72,7 +43,7 @@
   724     }
   725     t2: (struct){
   726       #A: (_){ _ }
   727-      l: (struct){
   728+      l: (#struct){
   729         f: (string){ "hi" }
   730       }
   731     }
   732@@ -88,7 +59,7 @@
   733       s: (struct){
   734         foo: (#struct){
   735           f: (#struct){
   736-            d: (struct){
   737+            d: (#struct){
   738               foo: (int){ 1 }
   739             }
   740           }
   741@@ -102,11 +73,11 @@
   742         }
   743       }
   744       W: (#struct){
   745-        a: (#struct){
   746-          b: (int){ 1 }
   747-        }
   748-        b: (struct){
   749-          c: (int){ 2 }
   750+        b: (#struct){
   751+          c: (int){ 2 }
   752+        }
   753+        a: (#struct){
   754+          b: (int){ 1 }
   755         }
   756       }
   757     }
   758@@ -120,10 +91,7 @@
   759         // [eval]
   760         c: (_|_){
   761           // [eval] ok.t5.x.c: field not allowed:
   762-          //     ./in.cue:35:6
   763           //     ./in.cue:36:3
   764-          //     ./in.cue:39:10
   765-          //     ./in.cue:40:5
   766           //     ./in.cue:41:5
   767         }
   768       }
   769@@ -179,7 +147,7 @@
   770     }
   771     t9: (struct){
   772       c: (#list){
   773-        0: (struct){
   774+        0: (#struct){
   775           b: (int){ int }
   776         }
   777       }
   778@@ -188,7 +156,7 @@
   779     }
   780     t10: (struct){
   781       #A: (_){ _ }
   782-      l: (struct){
   783+      l: (#struct){
   784         f: (string){ "hi" }
   785       }
   786     }
   787@@ -204,7 +172,7 @@
   788       s: (struct){
   789         foo: (#struct){
   790           f: (#struct){
   791-            d: (struct){
   792+            d: (#struct){
   793               foo: (string){ "bar" }
   794             }
   795           }
   796@@ -218,11 +186,11 @@
   797         }
   798       }
   799       W: (#struct){
   800-        a: (#struct){
   801-          b: (int){ 1 }
   802-        }
   803-        b: (struct){
   804-          c: (int){ 2 }
   805+        b: (#struct){
   806+          c: (int){ 2 }
   807+        }
   808+        a: (#struct){
   809+          b: (int){ 1 }
   810         }
   811       }
   812     }
   813@@ -236,10 +204,7 @@
   814         // [eval]
   815         c: (_|_){
   816           // [eval] ok.t13.x.c: field not allowed:
   817-          //     ./in.cue:106:6
   818           //     ./in.cue:107:3
   819-          //     ./in.cue:110:10
   820-          //     ./in.cue:111:5
   821           //     ./in.cue:112:5
   822         }
   823       }
   824@@ -263,13 +228,12 @@
   825       }
   826       a: (_|_){
   827         // [eval]
   828-        a: (int){ 2 }
   829         disallowed: (_|_){
   830           // [eval] err.t1.a.disallowed: field not allowed:
   831-          //     ./in.cue:128:10
   832           //     ./in.cue:129:5
   833           //     ./in.cue:130:5
   834         }
   835+        a: (int){ 2 }
   836       }
   837     }
   838     t2: (_|_){
   839@@ -283,14 +247,11 @@
   840         // [eval]
   841         c: (_|_){
   842           // [eval]
   843-          d: (int){ 1 }
   844           e: (_|_){
   845             // [eval] err.t2.V.c.e: field not allowed:
   846-            //     ./in.cue:134:8
   847-            //     ./in.cue:134:13
   848-            //     ./in.cue:135:5
   849             //     ./in.cue:136:10
   850           }
   851+          d: (int){ 1 }
   852         }
   853       }
   854     }
   855@@ -304,7 +265,6 @@
   856           // [eval]
   857           c: (_|_){
   858             // [eval] err.t3.p1.a.c: field not allowed:
   859-            //     ./in.cue:140:6
   860             //     ./in.cue:141:5
   861             //     ./in.cue:142:5
   862           }
   863@@ -322,8 +282,6 @@
   864             // [eval]
   865             c: (_|_){
   866               // [eval] err.t3.p2.a.b.c: field not allowed:
   867-              //     ./in.cue:146:9
   868-              //     ./in.cue:147:5
   869               //     ./in.cue:148:8
   870             }
   871           }
   872@@ -336,54 +294,47 @@
   873         // [eval]
   874         b: (_|_){
   875           // [eval]
   876-          f: (int){ 1 }
   877           h: (_|_){
   878             // [eval] err.t4.a.b.h: field not allowed:
   879-            //     ./in.cue:152:5
   880-            //     ./in.cue:153:9
   881             //     ./in.cue:154:8
   882           }
   883-        }
   884-      }
   885-      #A: (#struct){
   886-        b: (#struct){
   887-          f: (int){ 1 }
   888-        }
   889-      }
   890-    }
   891-    t5: (_|_){
   892-      // [eval]
   893-      a: (#struct){
   894-        b: (#struct){
   895-          f: (int){ 1 }
   896-          g: (int){ 1 }
   897-        }
   898-      }
   899-      #A: (#struct){
   900-        b: (#struct){
   901-          f: (int){ 1 }
   902-        }
   903-      }
   904-      #B: (#struct){
   905-        b: (#struct){
   906-          g: (int){ 1 }
   907-        }
   908-      }
   909-      b: (_|_){
   910-        // [eval]
   911-        b: (_|_){
   912-          // [eval]
   913-          f: (int){ 1 }
   914-          g: (int){ 1 }
   915+          f: (int){ 1 }
   916+        }
   917+      }
   918+      #A: (#struct){
   919+        b: (#struct){
   920+          f: (int){ 1 }
   921+        }
   922+      }
   923+    }
   924+    t5: (_|_){
   925+      // [eval]
   926+      a: (#struct){
   927+        b: (#struct){
   928+          f: (int){ 1 }
   929+          g: (int){ 1 }
   930+        }
   931+      }
   932+      #A: (#struct){
   933+        b: (#struct){
   934+          f: (int){ 1 }
   935+        }
   936+      }
   937+      #B: (#struct){
   938+        b: (#struct){
   939+          g: (int){ 1 }
   940+        }
   941+      }
   942+      b: (_|_){
   943+        // [eval]
   944+        b: (_|_){
   945+          // [eval]
   946           h: (_|_){
   947             // [eval] err.t5.b.b.h: field not allowed:
   948-            //     ./in.cue:159:6
   949-            //     ./in.cue:159:10
   950-            //     ./in.cue:160:9
   951-            //     ./in.cue:161:9
   952-            //     ./in.cue:162:5
   953             //     ./in.cue:163:8
   954           }
   955+          f: (int){ 1 }
   956+          g: (int){ 1 }
   957         }
   958       }
   959     }
   960@@ -433,17 +384,12 @@
   961               // [eval]
   962               e: (_|_){
   963                 // [eval]
   964-                f: (int){ 1 }
   965-                g: (int){ 1 }
   966                 h: (_|_){
   967                   // [eval] err.t6.b.b.c.d.e.h: field not allowed:
   968-                  //     ./in.cue:168:6
   969-                  //     ./in.cue:168:10
   970-                  //     ./in.cue:169:18
   971-                  //     ./in.cue:170:18
   972-                  //     ./in.cue:171:5
   973                   //     ./in.cue:172:17
   974                 }
   975+                f: (int){ 1 }
   976+                g: (int){ 1 }
   977               }
   978             }
   979           }
   980@@ -457,13 +403,12 @@
   981       }
   982       a: (_|_){
   983         // [eval]
   984-        a: (int){ 2 }
   985         b: (_|_){
   986           // [eval] err.t7.a.b: field not allowed:
   987-          //     ./in.cue:176:10
   988           //     ./in.cue:177:5
   989           //     ./in.cue:178:5
   990         }
   991+        a: (int){ 2 }
   992       }
   993     }
   994     t8: (_|_){
   995@@ -477,14 +422,11 @@
   996         // [eval]
   997         c: (_|_){
   998           // [eval]
   999-          d: (int){ 1 }
  1000           e: (_|_){
  1001             // [eval] err.t8.V.c.e: field not allowed:
  1002-            //     ./in.cue:183:8
  1003-            //     ./in.cue:183:13
  1004-            //     ./in.cue:184:5
  1005             //     ./in.cue:185:10
  1006           }
  1007+          d: (int){ 1 }
  1008         }
  1009       }
  1010     }
  1011-- diff/todo/p2 --
  1012error positions and reordering.
  1013-- out/eval --
  1014Errors:
  1015err.t1.a.disallowed: field not allowed:
  1016    ./in.cue:128:10
  1017    ./in.cue:129:5
  1018    ./in.cue:130:5
  1019err.t2.V.c.e: field not allowed:
  1020    ./in.cue:134:8
  1021    ./in.cue:134:13
  1022    ./in.cue:135:5
  1023    ./in.cue:136:10
  1024err.t3.p1.a.c: field not allowed:
  1025    ./in.cue:140:6
  1026    ./in.cue:141:5
  1027    ./in.cue:142:5
  1028err.t3.p2.a.b.c: field not allowed:
  1029    ./in.cue:146:9
  1030    ./in.cue:147:5
  1031    ./in.cue:148:8
  1032err.t4.a.b.h: field not allowed:
  1033    ./in.cue:152:5
  1034    ./in.cue:153:9
  1035    ./in.cue:154:8
  1036err.t5.b.b.h: field not allowed:
  1037    ./in.cue:159:6
  1038    ./in.cue:159:10
  1039    ./in.cue:160:9
  1040    ./in.cue:161:9
  1041    ./in.cue:162:5
  1042    ./in.cue:163:8
  1043err.t6.b.b.c.d.e.h: field not allowed:
  1044    ./in.cue:168:6
  1045    ./in.cue:168:10
  1046    ./in.cue:169:18
  1047    ./in.cue:170:18
  1048    ./in.cue:171:5
  1049    ./in.cue:172:17
  1050err.t7.a.b: field not allowed:
  1051    ./in.cue:176:10
  1052    ./in.cue:177:5
  1053    ./in.cue:178:5
  1054err.t8.V.c.e: field not allowed:
  1055    ./in.cue:183:8
  1056    ./in.cue:183:13
  1057    ./in.cue:184:5
  1058    ./in.cue:185:10
  1059ok.t13.x.c: field not allowed:
  1060    ./in.cue:106:6
  1061    ./in.cue:107:3
  1062    ./in.cue:110:10
  1063    ./in.cue:111:5
  1064    ./in.cue:112:5
  1065ok.t5.x.c: field not allowed:
  1066    ./in.cue:35:6
  1067    ./in.cue:36:3
  1068    ./in.cue:39:10
  1069    ./in.cue:40:5
  1070    ./in.cue:41:5
  1071
  1072Result:
  1073(_|_){
  1074  // [eval]
  1075  ok: (_|_){
  1076    // [eval]
  1077    t1: (struct){
  1078      c: (#list){
  1079        0: (struct){
  1080          b: (int){ int }
  1081        }
  1082      }
  1083      #R: (list){
  1084      }
  1085    }
  1086    t2: (struct){
  1087      #A: (_){ _ }
  1088      l: (struct){
  1089        f: (string){ "hi" }
  1090      }
  1091    }
  1092    t3: (struct){
  1093      #A: (#struct){
  1094        f: (#struct){
  1095        }
  1096      }
  1097      #A1: (#struct){
  1098        f: (#struct){
  1099        }
  1100      }
  1101      s: (struct){
  1102        foo: (#struct){
  1103          f: (#struct){
  1104            d: (struct){
  1105              foo: (int){ 1 }
  1106            }
  1107          }
  1108        }
  1109      }
  1110    }
  1111    t4: (struct){
  1112      #T: (#struct){
  1113        a: (#struct){
  1114          b: (int){ 1 }
  1115        }
  1116      }
  1117      W: (#struct){
  1118        a: (#struct){
  1119          b: (int){ 1 }
  1120        }
  1121        b: (struct){
  1122          c: (int){ 2 }
  1123        }
  1124      }
  1125    }
  1126    t5: (_|_){
  1127      // [eval]
  1128      #A: (#struct){
  1129      }
  1130      Common: (struct){
  1131      }
  1132      x: (_|_){
  1133        // [eval]
  1134        c: (_|_){
  1135          // [eval] ok.t5.x.c: field not allowed:
  1136          //     ./in.cue:35:6
  1137          //     ./in.cue:36:3
  1138          //     ./in.cue:39:10
  1139          //     ./in.cue:40:5
  1140          //     ./in.cue:41:5
  1141        }
  1142      }
  1143    }
  1144    t6: (struct){
  1145      #A: (#struct){
  1146      }
  1147      Common: (struct){
  1148      }
  1149      x: (#struct){
  1150        c: (int){ int }
  1151      }
  1152    }
  1153    t7: (struct){
  1154      a: (#struct){
  1155        b: (#struct){
  1156          f: (int){ 1 }
  1157          g: (int){ 1 }
  1158        }
  1159      }
  1160      #A: (#struct){
  1161        b: (#struct){
  1162          f: (int){ 1 }
  1163        }
  1164      }
  1165      #B: (#struct){
  1166        b: (#struct){
  1167          g: (int){ 1 }
  1168        }
  1169      }
  1170    }
  1171    t8: (struct){
  1172      foo: (#struct){
  1173        a: (#struct){
  1174          b: (#struct){
  1175            c: (#struct){
  1176              C: (int){ 1 }
  1177              D: (int){ 2 }
  1178            }
  1179          }
  1180        }
  1181      }
  1182      #X: (#struct){
  1183        a: (#struct){
  1184          b: (#struct){
  1185            c: (#struct){
  1186              C: (int){ 1 }
  1187              D: (int){ 2 }
  1188            }
  1189          }
  1190        }
  1191      }
  1192    }
  1193    t9: (struct){
  1194      c: (#list){
  1195        0: (struct){
  1196          b: (int){ int }
  1197        }
  1198      }
  1199      #R: (list){
  1200      }
  1201    }
  1202    t10: (struct){
  1203      #A: (_){ _ }
  1204      l: (struct){
  1205        f: (string){ "hi" }
  1206      }
  1207    }
  1208    t11: (struct){
  1209      #A: (#struct){
  1210        f: (#struct){
  1211        }
  1212      }
  1213      #A1: (#struct){
  1214        f: (#struct){
  1215        }
  1216      }
  1217      s: (struct){
  1218        foo: (#struct){
  1219          f: (#struct){
  1220            d: (struct){
  1221              foo: (string){ "bar" }
  1222            }
  1223          }
  1224        }
  1225      }
  1226    }
  1227    t12: (struct){
  1228      #T: (#struct){
  1229        a: (#struct){
  1230          b: (int){ 1 }
  1231        }
  1232      }
  1233      W: (#struct){
  1234        a: (#struct){
  1235          b: (int){ 1 }
  1236        }
  1237        b: (struct){
  1238          c: (int){ 2 }
  1239        }
  1240      }
  1241    }
  1242    t13: (_|_){
  1243      // [eval]
  1244      #A: (#struct){
  1245      }
  1246      Common: (struct){
  1247      }
  1248      x: (_|_){
  1249        // [eval]
  1250        c: (_|_){
  1251          // [eval] ok.t13.x.c: field not allowed:
  1252          //     ./in.cue:106:6
  1253          //     ./in.cue:107:3
  1254          //     ./in.cue:110:10
  1255          //     ./in.cue:111:5
  1256          //     ./in.cue:112:5
  1257        }
  1258      }
  1259    }
  1260    t14: (struct){
  1261      #A: (#struct){
  1262      }
  1263      Common: (struct){
  1264      }
  1265      x: (#struct){
  1266        c: (int){ int }
  1267      }
  1268    }
  1269  }
  1270  err: (_|_){
  1271    // [eval]
  1272    t1: (_|_){
  1273      // [eval]
  1274      #D: (#struct){
  1275        a: (int){ 2 }
  1276      }
  1277      a: (_|_){
  1278        // [eval]
  1279        a: (int){ 2 }
  1280        disallowed: (_|_){
  1281          // [eval] err.t1.a.disallowed: field not allowed:
  1282          //     ./in.cue:128:10
  1283          //     ./in.cue:129:5
  1284          //     ./in.cue:130:5
  1285        }
  1286      }
  1287    }
  1288    t2: (_|_){
  1289      // [eval]
  1290      #S: (#struct){
  1291        c: (#struct){
  1292          d: (int){ 1 }
  1293        }
  1294      }
  1295      V: (_|_){
  1296        // [eval]
  1297        c: (_|_){
  1298          // [eval]
  1299          d: (int){ 1 }
  1300          e: (_|_){
  1301            // [eval] err.t2.V.c.e: field not allowed:
  1302            //     ./in.cue:134:8
  1303            //     ./in.cue:134:13
  1304            //     ./in.cue:135:5
  1305            //     ./in.cue:136:10
  1306          }
  1307        }
  1308      }
  1309    }
  1310    t3: (_|_){
  1311      // [eval]
  1312      p1: (_|_){
  1313        // [eval]
  1314        #D: (#struct){
  1315        }
  1316        a: (_|_){
  1317          // [eval]
  1318          c: (_|_){
  1319            // [eval] err.t3.p1.a.c: field not allowed:
  1320            //     ./in.cue:140:6
  1321            //     ./in.cue:141:5
  1322            //     ./in.cue:142:5
  1323          }
  1324        }
  1325      }
  1326      p2: (_|_){
  1327        // [eval]
  1328        #D: (#struct){
  1329          b: (#struct){
  1330          }
  1331        }
  1332        a: (_|_){
  1333          // [eval]
  1334          b: (_|_){
  1335            // [eval]
  1336            c: (_|_){
  1337              // [eval] err.t3.p2.a.b.c: field not allowed:
  1338              //     ./in.cue:146:9
  1339              //     ./in.cue:147:5
  1340              //     ./in.cue:148:8
  1341            }
  1342          }
  1343        }
  1344      }
  1345    }
  1346    t4: (_|_){
  1347      // [eval]
  1348      a: (_|_){
  1349        // [eval]
  1350        b: (_|_){
  1351          // [eval]
  1352          f: (int){ 1 }
  1353          h: (_|_){
  1354            // [eval] err.t4.a.b.h: field not allowed:
  1355            //     ./in.cue:152:5
  1356            //     ./in.cue:153:9
  1357            //     ./in.cue:154:8
  1358          }
  1359        }
  1360      }
  1361      #A: (#struct){
  1362        b: (#struct){
  1363          f: (int){ 1 }
  1364        }
  1365      }
  1366    }
  1367    t5: (_|_){
  1368      // [eval]
  1369      a: (#struct){
  1370        b: (#struct){
  1371          f: (int){ 1 }
  1372          g: (int){ 1 }
  1373        }
  1374      }
  1375      #A: (#struct){
  1376        b: (#struct){
  1377          f: (int){ 1 }
  1378        }
  1379      }
  1380      #B: (#struct){
  1381        b: (#struct){
  1382          g: (int){ 1 }
  1383        }
  1384      }
  1385      b: (_|_){
  1386        // [eval]
  1387        b: (_|_){
  1388          // [eval]
  1389          f: (int){ 1 }
  1390          g: (int){ 1 }
  1391          h: (_|_){
  1392            // [eval] err.t5.b.b.h: field not allowed:
  1393            //     ./in.cue:159:6
  1394            //     ./in.cue:159:10
  1395            //     ./in.cue:160:9
  1396            //     ./in.cue:161:9
  1397            //     ./in.cue:162:5
  1398            //     ./in.cue:163:8
  1399          }
  1400        }
  1401      }
  1402    }
  1403    t6: (_|_){
  1404      // [eval]
  1405      a: (#struct){
  1406        b: (#struct){
  1407          c: (#struct){
  1408            d: (#struct){
  1409              e: (#struct){
  1410                f: (int){ 1 }
  1411                g: (int){ 1 }
  1412              }
  1413            }
  1414          }
  1415        }
  1416      }
  1417      #A: (#struct){
  1418        b: (#struct){
  1419          c: (#struct){
  1420            d: (#struct){
  1421              e: (#struct){
  1422                f: (int){ 1 }
  1423              }
  1424            }
  1425          }
  1426        }
  1427      }
  1428      #B: (#struct){
  1429        b: (#struct){
  1430          c: (#struct){
  1431            d: (#struct){
  1432              e: (#struct){
  1433                g: (int){ 1 }
  1434              }
  1435            }
  1436          }
  1437        }
  1438      }
  1439      b: (_|_){
  1440        // [eval]
  1441        b: (_|_){
  1442          // [eval]
  1443          c: (_|_){
  1444            // [eval]
  1445            d: (_|_){
  1446              // [eval]
  1447              e: (_|_){
  1448                // [eval]
  1449                f: (int){ 1 }
  1450                g: (int){ 1 }
  1451                h: (_|_){
  1452                  // [eval] err.t6.b.b.c.d.e.h: field not allowed:
  1453                  //     ./in.cue:168:6
  1454                  //     ./in.cue:168:10
  1455                  //     ./in.cue:169:18
  1456                  //     ./in.cue:170:18
  1457                  //     ./in.cue:171:5
  1458                  //     ./in.cue:172:17
  1459                }
  1460              }
  1461            }
  1462          }
  1463        }
  1464      }
  1465    }
  1466    t7: (_|_){
  1467      // [eval]
  1468      #D: (#struct){
  1469        a: (int){ 2 }
  1470      }
  1471      a: (_|_){
  1472        // [eval]
  1473        a: (int){ 2 }
  1474        b: (_|_){
  1475          // [eval] err.t7.a.b: field not allowed:
  1476          //     ./in.cue:176:10
  1477          //     ./in.cue:177:5
  1478          //     ./in.cue:178:5
  1479        }
  1480      }
  1481    }
  1482    t8: (_|_){
  1483      // [eval]
  1484      #S: (#struct){
  1485        c: (#struct){
  1486          d: (int){ 1 }
  1487        }
  1488      }
  1489      V: (_|_){
  1490        // [eval]
  1491        c: (_|_){
  1492          // [eval]
  1493          d: (int){ 1 }
  1494          e: (_|_){
  1495            // [eval] err.t8.V.c.e: field not allowed:
  1496            //     ./in.cue:183:8
  1497            //     ./in.cue:183:13
  1498            //     ./in.cue:184:5
  1499            //     ./in.cue:185:10
  1500          }
  1501        }
  1502      }
  1503    }
  1504  }
  1505}
  1506-- out/compile --
  1507--- in.cue
  1508{
  1509  ok: {
  1510    t1: {
  1511      c: 〈0;#R〉
  1512      c: [
  1513        {
  1514          b: int
  1515        },
  1516      ]
  1517      #R: [
  1518        ...,
  1519      ]
  1520    }
  1521  }
  1522  ok: {
  1523    t2: {
  1524      #A: _
  1525      l: 〈0;#A〉
  1526      l: {
  1527        f: "hi"
  1528      }
  1529    }
  1530  }
  1531  ok: {
  1532    t3: {
  1533      #A: {
  1534        f: {
  1535          ...
  1536        }
  1537      }
  1538      #A1: {
  1539        〈1;#A〉
  1540      }
  1541      s: {
  1542        [string]: 〈1;#A1〉
  1543      }
  1544      s: {
  1545        foo: {
  1546          f: {
  1547            d: {
  1548              foo: 1
  1549            }
  1550          }
  1551        }
  1552      }
  1553    }
  1554  }
  1555  ok: {
  1556    t4: {
  1557      #T: {
  1558        a: {
  1559          b: 1
  1560        }
  1561      }
  1562      W: {
  1563        {
  1564          〈2;#T〉
  1565        }
  1566        b: {
  1567          c: 2
  1568        }
  1569      }
  1570    }
  1571  }
  1572  ok: {
  1573    t5: {
  1574      #A: {
  1575        〈1;Common〉
  1576        _
  1577      }
  1578      Common: {}
  1579      x: 〈0;#A〉
  1580      x: {
  1581        c: int
  1582      }
  1583    }
  1584  }
  1585  ok: {
  1586    t6: {
  1587      #A: {
  1588        〈1;Common〉
  1589        ...
  1590      }
  1591      Common: {}
  1592      x: 〈0;#A〉
  1593      x: {
  1594        c: int
  1595      }
  1596    }
  1597  }
  1598  ok: {
  1599    t7: {
  1600      a: {
  1601        〈1;#A〉
  1602        〈1;#B〉
  1603      }
  1604      #A: {
  1605        b: {
  1606          f: 1
  1607        }
  1608      }
  1609      #B: {
  1610        b: {
  1611          g: 1
  1612        }
  1613      }
  1614    }
  1615  }
  1616  ok: {
  1617    t8: {
  1618      foo: 〈0;#X〉
  1619      #X: {
  1620        a: {
  1621          b: {
  1622            c: {
  1623              C: 1
  1624            }
  1625          }
  1626        }
  1627        for k, _ in 〈0;a〉 {
  1628          a: {
  1629            〈2;k〉: {
  1630              c: {
  1631                D: 2
  1632              }
  1633            }
  1634          }
  1635        }
  1636      }
  1637    }
  1638  }
  1639  ok: {
  1640    t9: {
  1641      c: 〈0;#R〉
  1642      c: [
  1643        {
  1644          b: int
  1645        },
  1646      ]
  1647      #R: [
  1648        ...,
  1649      ]
  1650    }
  1651  }
  1652  ok: {
  1653    t10: {
  1654      #A: _
  1655      l: 〈0;#A〉
  1656      l: {
  1657        f: "hi"
  1658      }
  1659    }
  1660  }
  1661  ok: {
  1662    t11: {
  1663      #A: {
  1664        f: {
  1665          ...
  1666        }
  1667      }
  1668      #A1: {
  1669        〈1;#A〉
  1670      }
  1671      s: {
  1672        [string]: 〈1;#A1〉
  1673      }
  1674      s: {
  1675        foo: {
  1676          f: {
  1677            d: {
  1678              foo: "bar"
  1679            }
  1680          }
  1681        }
  1682      }
  1683    }
  1684  }
  1685  ok: {
  1686    t12: {
  1687      #T: {
  1688        a: {
  1689          b: 1
  1690        }
  1691      }
  1692      W: {
  1693        {
  1694          〈2;#T〉
  1695        }
  1696        b: {
  1697          c: 2
  1698        }
  1699      }
  1700    }
  1701  }
  1702  ok: {
  1703    t13: {
  1704      #A: {
  1705        〈1;Common〉
  1706        _
  1707      }
  1708      Common: {}
  1709      x: 〈0;#A〉
  1710      x: {
  1711        c: int
  1712      }
  1713    }
  1714  }
  1715  ok: {
  1716    t14: {
  1717      #A: {
  1718        〈1;Common〉
  1719        ...
  1720      }
  1721      Common: {}
  1722      x: 〈0;#A〉
  1723      x: {
  1724        c: int
  1725      }
  1726    }
  1727  }
  1728  err: {
  1729    t1: {
  1730      #D: (_ & {
  1731        a: 2
  1732      })
  1733      a: 〈0;#D〉
  1734      a: {
  1735        disallowed: 1
  1736      }
  1737    }
  1738  }
  1739  err: {
  1740    t2: {
  1741      #S: {
  1742        {
  1743          c: {
  1744            d: 1
  1745          }
  1746        }
  1747      }
  1748      V: 〈0;#S〉
  1749      V: {
  1750        c: {
  1751          e: 1
  1752        }
  1753      }
  1754    }
  1755  }
  1756  err: {
  1757    t3: {
  1758      p1: {
  1759        #D: {}
  1760        a: 〈0;#D〉
  1761        a: {
  1762          c: "C"
  1763        }
  1764      }
  1765    }
  1766  }
  1767  err: {
  1768    t3: {
  1769      p2: {
  1770        #D: {
  1771          b: {}
  1772        }
  1773        a: 〈0;#D〉
  1774        a: {
  1775          b: {
  1776            c: "C"
  1777          }
  1778        }
  1779      }
  1780    }
  1781  }
  1782  err: {
  1783    t4: {
  1784      a: 〈0;#A〉
  1785      #A: {
  1786        b: {
  1787          f: 1
  1788        }
  1789      }
  1790      a: {
  1791        b: {
  1792          h: 1
  1793        }
  1794      }
  1795    }
  1796  }
  1797  err: {
  1798    t5: {
  1799      a: {
  1800        〈1;#A〉
  1801        〈1;#B〉
  1802      }
  1803      #A: {
  1804        b: {
  1805          f: 1
  1806        }
  1807      }
  1808      #B: {
  1809        b: {
  1810          g: 1
  1811        }
  1812      }
  1813      b: 〈0;a〉
  1814      b: {
  1815        b: {
  1816          h: 1
  1817        }
  1818      }
  1819    }
  1820  }
  1821  err: {
  1822    t6: {
  1823      a: {
  1824        〈1;#A〉
  1825        〈1;#B〉
  1826      }
  1827      #A: {
  1828        b: {
  1829          c: {
  1830            d: {
  1831              e: {
  1832                f: 1
  1833              }
  1834            }
  1835          }
  1836        }
  1837      }
  1838      #B: {
  1839        b: {
  1840          c: {
  1841            d: {
  1842              e: {
  1843                g: 1
  1844              }
  1845            }
  1846          }
  1847        }
  1848      }
  1849      b: 〈0;a〉
  1850      b: {
  1851        b: {
  1852          c: {
  1853            d: {
  1854              e: {
  1855                h: 1
  1856              }
  1857            }
  1858          }
  1859        }
  1860      }
  1861    }
  1862  }
  1863  err: {
  1864    t7: {
  1865      #D: (_ & {
  1866        a: 2
  1867      })
  1868      a: 〈0;#D〉
  1869      a: {
  1870        b: 1
  1871      }
  1872    }
  1873  }
  1874  err: {
  1875    t8: {
  1876      #S: {
  1877        {
  1878          c: {
  1879            d: 1
  1880          }
  1881        }
  1882      }
  1883      V: 〈0;#S〉
  1884      V: {
  1885        c: {
  1886          e: 1
  1887        }
  1888      }
  1889    }
  1890  }
  1891}

View as plain text