github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/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  -- out/eval --
    20  Errors:
    21  fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
    22      ./in.cue:2:9
    23      ./in.cue:2:17
    24  fatalChild.0.a: undefined field: c:
    25      ./in.cue:8:17
    26  
    27  Result:
    28  (_|_){
    29    // [eval]
    30    fatalArg: (_|_){
    31      // [eval]
    32      x: (_|_){
    33        // [eval] fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
    34        //     ./in.cue:2:9
    35        //     ./in.cue:2:17
    36      }
    37    }
    38    fatalChild: (_|_){
    39      // [eval]
    40      #b: (#struct){
    41      }
    42      x: (_|_){
    43        // [eval] fatalChild.0.a: undefined field: c:
    44        //     ./in.cue:8:17
    45      }
    46    }
    47    okIncompleteChild: (struct){
    48      b: (struct){
    49      }
    50      x: (struct){
    51        a: (_|_){
    52          // [incomplete] okIncompleteChild.x.a: undefined field: c:
    53          //     ./in.cue:16:16
    54        }
    55        b: (int){ 1 }
    56      }
    57    }
    58  }
    59  -- out/compile --
    60  --- in.cue
    61  {
    62    fatalArg: {
    63      x: len(("eee" + 'eee'))
    64    }
    65    fatalChild: {
    66      #b: {}
    67      x: and([
    68        {
    69          a: 〈2;#b〉.c
    70        },
    71      ])
    72    }
    73    okIncompleteChild: {
    74      b: {}
    75      x: and([
    76        {
    77          a: 〈2;b〉.c
    78        },
    79        {
    80          b: 1
    81        },
    82      ])
    83    }
    84  }