github.com/solo-io/cue@v0.4.7/cue/testdata/comprehensions/for.txtar (about)

     1  -- in.cue --
     2  b: { for k, v in a { "\(k)": v+1 } }
     3  a: { b: 1, c: 2 }
     4  
     5  x: { for k, v in y { "\(k)": v } }
     6  y: {} // check that empty struct after reference works.
     7  
     8  k: { for v in e { v } }
     9  e: int
    10  -- out/eval --
    11  Errors:
    12  k: invalid operand e (found int, want list or struct):
    13      ./in.cue:7:15
    14  
    15  Result:
    16  (_|_){
    17    // [eval]
    18    b: (struct){
    19      b: (int){ 2 }
    20      c: (int){ 3 }
    21    }
    22    a: (struct){
    23      b: (int){ 1 }
    24      c: (int){ 2 }
    25    }
    26    x: (struct){
    27    }
    28    y: (struct){
    29    }
    30    k: (_|_){
    31      // [eval] k: invalid operand e (found int, want list or struct):
    32      //     ./in.cue:7:15
    33    }
    34    e: (int){ int }
    35  }
    36  -- out/compile --
    37  --- in.cue
    38  {
    39    b: {
    40      for k, v in 〈1;a〉 {
    41        "\(〈1;k〉)": (〈1;v〉 + 1)
    42      }
    43    }
    44    a: {
    45      b: 1
    46      c: 2
    47    }
    48    x: {
    49      for k, v in 〈1;y〉 {
    50        "\(〈1;k〉)": 〈1;v〉
    51      }
    52    }
    53    y: {}
    54    k: {
    55      for _, v in 〈1;e〉 {
    56        〈1;v〉
    57      }
    58    }
    59    e: int
    60  }