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

     1  -- in.cue --
     2  #a: {
     3  	val:    string
     4  	result: string
     5  }
     6  
     7  a: #a & {
     8  	val:    *"default" | string
     9  	result: *"not-matched" | string
    10  	if (val == "match") {
    11  		result: "matched"
    12  	}
    13  }
    14  
    15  match: a & {
    16  	val: "match"
    17  }
    18  
    19  not: a & {
    20  	val: "other"
    21  }
    22  -- out/eval/stats --
    23  Leaks:  0
    24  Freed:  25
    25  Reused: 20
    26  Allocs: 5
    27  Retain: 0
    28  
    29  Unifications: 13
    30  Conjuncts:    44
    31  Disjuncts:    25
    32  -- out/eval --
    33  (struct){
    34    #a: (#struct){
    35      val: (string){ string }
    36      result: (string){ string }
    37    }
    38    a: (#struct){
    39      val: (string){ |(*(string){ "default" }, (string){ string }) }
    40      result: (string){ |(*(string){ "not-matched" }, (string){ string }) }
    41    }
    42    match: (#struct){
    43      val: (string){ "match" }
    44      result: (string){ "matched" }
    45    }
    46    not: (#struct){
    47      val: (string){ "other" }
    48      result: (string){ |(*(string){ "not-matched" }, (string){ string }) }
    49    }
    50  }
    51  -- out/compile --
    52  --- in.cue
    53  {
    54    #a: {
    55      val: string
    56      result: string
    57    }
    58    a: (〈0;#a〉 & {
    59      val: (*"default"|string)
    60      result: (*"not-matched"|string)
    61      if (〈0;val〉 == "match") {
    62        result: "matched"
    63      }
    64    })
    65    match: (〈0;a〉 & {
    66      val: "match"
    67    })
    68    not: (〈0;a〉 & {
    69      val: "other"
    70    })
    71  }