cuelang.org/go@v0.10.1/cue/testdata/comprehensions/issue507.txtar (about)

     1  -- in.cue --
     2  package x
     3  
     4  somelist: [...string] | *[]
     5  // Works just fine
     6  foo: [
     7  	for e in somelist {
     8  		"hello foo: \(e)"
     9  	},
    10  ]
    11  
    12  otherlist: ["something"]
    13  // Works fine as well
    14  z: [
    15  	for e in otherlist {
    16  		"hello z: \(e)"
    17  	},
    18  ]
    19  
    20  extlist: [...string] | *["something"]
    21  bar: [
    22  	for e in extlist {
    23  		"hello bar: \(e)"
    24  	},
    25  ]
    26  -- out/eval/stats --
    27  Leaks:  0
    28  Freed:  15
    29  Reused: 10
    30  Allocs: 5
    31  Retain: 0
    32  
    33  Unifications: 11
    34  Conjuncts:    17
    35  Disjuncts:    15
    36  -- out/eval --
    37  (struct){
    38    somelist: (list){ |(*(#list){
    39      }, (list){
    40      }) }
    41    foo: (#list){
    42    }
    43    otherlist: (#list){
    44      0: (string){ "something" }
    45    }
    46    z: (#list){
    47      0: (string){ "hello z: something" }
    48    }
    49    extlist: (list){ |(*(#list){
    50        0: (string){ "something" }
    51      }, (list){
    52      }) }
    53    bar: (#list){
    54      0: (string){ "hello bar: something" }
    55    }
    56  }
    57  -- out/compile --
    58  --- in.cue
    59  {
    60    somelist: ([
    61      ...string,
    62    ]|*[])
    63    foo: [
    64      for _, e in 〈1;somelist〉 {
    65        "hello foo: \(〈1;e〉)"
    66      },
    67    ]
    68    otherlist: [
    69      "something",
    70    ]
    71    z: [
    72      for _, e in 〈1;otherlist〉 {
    73        "hello z: \(〈1;e〉)"
    74      },
    75    ]
    76    extlist: ([
    77      ...string,
    78    ]|*[
    79      "something",
    80    ])
    81    bar: [
    82      for _, e in 〈1;extlist〉 {
    83        "hello bar: \(〈1;e〉)"
    84      },
    85    ]
    86  }