cuelang.org/go@v0.13.0/cue/testdata/builtins/all.txtar (about)

     1  -- in.cue --
     2  fatalArg: {
     3  	x: len("eee" + 'eee')
     4  }
     5  
     6  // don't call builtin for a permanent error of a child node
     7  fatalChild: {
     8  	#b: {}
     9  	x: and([{a: #b.c}])
    10  }
    11  
    12  // allow incomplete child values. The error will persist after `and` is
    13  // evaluated down the line. This allows the and-ing of templates that may
    14  // complete later.
    15  okIncompleteChild: {
    16  	b: {}
    17  	x: and([{a: b.c}, {b: 1}])
    18  }
    19  -- issue3412.cue --
    20  andInPattern: {
    21  	out: {
    22  		[and(#constraints)]: _
    23  		someKey: {}
    24  	}
    25  	#constraints: [=~"^.*$"]
    26  }
    27  -- out/eval/stats --
    28  Leaks:  2
    29  Freed:  18
    30  Reused: 12
    31  Allocs: 8
    32  Retain: 3
    33  
    34  Unifications: 20
    35  Conjuncts:    27
    36  Disjuncts:    21
    37  -- out/eval --
    38  Errors:
    39  fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
    40      ./in.cue:2:9
    41      ./in.cue:2:17
    42  fatalChild.x.a: undefined field: c:
    43      ./in.cue:8:17
    44  
    45  Result:
    46  (_|_){
    47    // [eval]
    48    fatalArg: (_|_){
    49      // [eval]
    50      x: (_|_){
    51        // [eval] fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
    52        //     ./in.cue:2:9
    53        //     ./in.cue:2:17
    54      }
    55    }
    56    fatalChild: (_|_){
    57      // [eval]
    58      #b: (#struct){
    59      }
    60      x: (_|_){
    61        // [eval]
    62        a: (_|_){
    63          // [eval] fatalChild.x.a: undefined field: c:
    64          //     ./in.cue:8:17
    65        }
    66      }
    67    }
    68    okIncompleteChild: (struct){
    69      b: (struct){
    70      }
    71      x: (struct){
    72        a: (_|_){
    73          // [incomplete] okIncompleteChild.x.a: undefined field: c:
    74          //     ./in.cue:16:16
    75        }
    76        b: (int){ 1 }
    77      }
    78    }
    79    andInPattern: (struct){
    80      out: (struct){
    81        someKey: (struct){
    82        }
    83      }
    84      #constraints: (#list){
    85        0: (string){ =~"^.*$" }
    86      }
    87    }
    88  }
    89  -- out/compile --
    90  --- in.cue
    91  {
    92    fatalArg: {
    93      x: len(("eee" + 'eee'))
    94    }
    95    fatalChild: {
    96      #b: {}
    97      x: and([
    98        {
    99          a: 〈2;#b〉.c
   100        },
   101      ])
   102    }
   103    okIncompleteChild: {
   104      b: {}
   105      x: and([
   106        {
   107          a: 〈2;b〉.c
   108        },
   109        {
   110          b: 1
   111        },
   112      ])
   113    }
   114  }
   115  --- issue3412.cue
   116  {
   117    andInPattern: {
   118      out: {
   119        [and(〈1;#constraints〉)]: _
   120        someKey: {}
   121      }
   122      #constraints: [
   123        =~"^.*$",
   124      ]
   125    }
   126  }