cuelang.org/go@v0.13.0/cue/testdata/resolve/025_definitions.txtar (about)

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