cuelang.org/go@v0.10.1/cue/testdata/references/value.txtar (about)

     1  -- in.cue --
     2  structShorthand: X={b: 3, c: X.b}
     3  
     4  // Note that X and Y are subtly different, as they have different bindings:
     5  // one binds to the field, the other to the value. In this case, that does not
     6  // make a difference.
     7  fieldAndValue: X=foo: Y={3, #sum: X + Y}
     8  
     9  valueCycle: b: X=3 + X
    10  
    11  // Issue #1003
    12  listValueAlias: X = [1, 2, X[0]]
    13  -- out/eval/stats --
    14  Leaks:  0
    15  Freed:  13
    16  Reused: 9
    17  Allocs: 4
    18  Retain: 0
    19  
    20  Unifications: 13
    21  Conjuncts:    20
    22  Disjuncts:    13
    23  -- out/evalalpha --
    24  (struct){
    25    structShorthand: (struct){
    26      b: (int){ 3 }
    27      c: (int){ 3 }
    28    }
    29    fieldAndValue: (struct){
    30      foo: (int){
    31        3
    32        #sum: (int){ 6 }
    33      }
    34    }
    35    valueCycle: (struct){
    36      b: (_|_){
    37        // [incomplete] valueCycle.b: non-concrete value _ in operand to +:
    38        //     ./in.cue:8:18
    39      }
    40    }
    41    listValueAlias: (#list){
    42      0: (int){ 1 }
    43      1: (int){ 2 }
    44      2: (int){ 1 }
    45    }
    46  }
    47  -- diff/-out/evalalpha<==>+out/eval --
    48  diff old new
    49  --- old
    50  +++ new
    51  @@ -11,7 +11,7 @@
    52     }
    53     valueCycle: (struct){
    54       b: (_|_){
    55  -      // [cycle] cycle error:
    56  +      // [incomplete] valueCycle.b: non-concrete value _ in operand to +:
    57         //     ./in.cue:8:18
    58       }
    59     }
    60  -- diff/explanation --
    61  Improved error message.
    62  -- out/eval --
    63  (struct){
    64    structShorthand: (struct){
    65      b: (int){ 3 }
    66      c: (int){ 3 }
    67    }
    68    fieldAndValue: (struct){
    69      foo: (int){
    70        3
    71        #sum: (int){ 6 }
    72      }
    73    }
    74    valueCycle: (struct){
    75      b: (_|_){
    76        // [cycle] cycle error:
    77        //     ./in.cue:8:18
    78      }
    79    }
    80    listValueAlias: (#list){
    81      0: (int){ 1 }
    82      1: (int){ 2 }
    83      2: (int){ 1 }
    84    }
    85  }
    86  -- out/compile --
    87  --- in.cue
    88  {
    89    structShorthand: {
    90      b: 3
    91      c: 〈1〉.b
    92    }
    93    fieldAndValue: {
    94      foo: {
    95        3
    96        #sum: (〈1;foo〉 + 〈1〉)
    97      }
    98    }
    99    valueCycle: {
   100      b: (3 + 〈0〉)
   101    }
   102    listValueAlias: [
   103      1,
   104      2,
   105      〈1〉[0],
   106    ]
   107  }