...

Text file src/cuelang.org/go/cue/testdata/comprehensions/issue507.txtar

Documentation: cuelang.org/go/cue/testdata/comprehensions

     1-- in.cue --
     2package x
     3
     4somelist: [...string] | *[]
     5// Works just fine
     6foo: [
     7	for e in somelist {
     8		"hello foo: \(e)"
     9	},
    10]
    11
    12otherlist: ["something"]
    13// Works fine as well
    14z: [
    15	for e in otherlist {
    16		"hello z: \(e)"
    17	},
    18]
    19
    20extlist: [...string] | *["something"]
    21bar: [
    22	for e in extlist {
    23		"hello bar: \(e)"
    24	},
    25]
    26-- out/eval/stats --
    27Leaks:  0
    28Freed:  15
    29Reused: 10
    30Allocs: 5
    31Retain: 0
    32
    33Unifications: 11
    34Conjuncts:    17
    35Disjuncts:    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}

View as plain text