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

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