github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/cue/testdata/definitions/037_closing_with_comprehensions.txtar (about)

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: closing with comprehensions
     4  #evalPartial
     5  -- in.cue --
     6  #A: {f1: int, f2: int}
     7  
     8  for k, v in {f3: int} {
     9  	a: #A & {"\(k)": v}
    10  }
    11  
    12  #B: {
    13  	for k, v in {f1: int} {
    14  		"\(k)": v
    15  	}
    16  }
    17  
    18  #C: {
    19  	f1: _
    20  	for k, v in {f1: int} {
    21  		"\(k)": v
    22  	}
    23  }
    24  
    25  #D: {
    26  	for k, v in {f1: int} {
    27  		"\(k)": v
    28  	}
    29  	...
    30  }
    31  
    32  #E: #A & {
    33  	for k, v in {f3: int} {
    34  		"\(k)": v
    35  	}
    36  }
    37  -- out/def --
    38  #A: {
    39  	f1: int
    40  	f2: int
    41  }
    42  a: _|_ // field "f3" not allowed in closed struct
    43  #B: {
    44  	f1: v
    45  }
    46  #C: {
    47  	f1: {
    48  		_
    49  		v
    50  		...
    51  	}
    52  }
    53  #D: {
    54  	f1: v
    55  	...
    56  }
    57  #E: _|_ // field "f3" not allowed in closed struct
    58  -- out/legacy-debug --
    59  <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)}
    60  -- out/compile --
    61  --- in.cue
    62  {
    63    #A: {
    64      f1: int
    65      f2: int
    66    }
    67    for k, v in {
    68      f3: int
    69    } {
    70      a: (〈2;#A〉 & {
    71        "\(〈2;k〉)": 〈2;v〉
    72      })
    73    }
    74    #B: {
    75      for k, v in {
    76        f1: int
    77      } {
    78        "\(〈1;k〉)": 〈1;v〉
    79      }
    80    }
    81    #C: {
    82      f1: _
    83      for k, v in {
    84        f1: int
    85      } {
    86        "\(〈1;k〉)": 〈1;v〉
    87      }
    88    }
    89    #D: {
    90      for k, v in {
    91        f1: int
    92      } {
    93        "\(〈1;k〉)": 〈1;v〉
    94      }
    95      ...
    96    }
    97    #E: (〈0;#A〉 & {
    98      for k, v in {
    99        f3: int
   100      } {
   101        "\(〈1;k〉)": 〈1;v〉
   102      }
   103    })
   104  }
   105  -- out/eval --
   106  Errors:
   107  #E: field not allowed: f3:
   108      ./in.cue:1:5
   109      ./in.cue:27:5
   110      ./in.cue:27:10
   111      ./in.cue:28:2
   112      ./in.cue:29:3
   113  a: field not allowed: f3:
   114      ./in.cue:1:5
   115      ./in.cue:3:1
   116      ./in.cue:4:5
   117      ./in.cue:4:11
   118  
   119  Result:
   120  (_|_){
   121    // [eval]
   122    #A: (#struct){
   123      f1: (int){ int }
   124      f2: (int){ int }
   125    }
   126    #B: (#struct){
   127      f1: (int){ int }
   128    }
   129    #C: (#struct){
   130      f1: (int){ int }
   131    }
   132    #D: (#struct){
   133      f1: (int){ int }
   134    }
   135    #E: (_|_){
   136      // [eval]
   137      f1: (int){ int }
   138      f2: (int){ int }
   139      f3: (_|_){
   140        // [eval] #E: field not allowed: f3:
   141        //     ./in.cue:1:5
   142        //     ./in.cue:27:5
   143        //     ./in.cue:27:10
   144        //     ./in.cue:28:2
   145        //     ./in.cue:29:3
   146      }
   147    }
   148    a: (_|_){
   149      // [eval]
   150      f1: (int){ int }
   151      f2: (int){ int }
   152      f3: (_|_){
   153        // [eval] a: field not allowed: f3:
   154        //     ./in.cue:1:5
   155        //     ./in.cue:3:1
   156        //     ./in.cue:4:5
   157        //     ./in.cue:4:11
   158      }
   159    }
   160  }