-- in.cue --
fatalArg: {
	x: len("eee" + 'eee')
}

// don't call builtin for a permanent error of a child node
fatalChild: {
	#b: {}
	x: and([{a: #b.c}])
}

// allow incomplete child values. The error will persist after `and` is
// evaluated down the line. This allows the and-ing of templates that may
// complete later.
okIncompleteChild: {
	b: {}
	x: and([{a: b.c}, {b: 1}])
}
-- issue3412.cue --
andInPattern: {
	out: {
		[and(#constraints)]: _
		someKey: {}
	}
	#constraints: [=~"^.*$"]
}
-- out/eval/stats --
Leaks:  2
Freed:  18
Reused: 12
Allocs: 8
Retain: 3

Unifications: 20
Conjuncts:    27
Disjuncts:    21
-- out/eval --
Errors:
fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
    ./in.cue:2:9
    ./in.cue:2:17
fatalChild.x.a: undefined field: c:
    ./in.cue:8:17

Result:
(_|_){
  // [eval]
  fatalArg: (_|_){
    // [eval]
    x: (_|_){
      // [eval] fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
      //     ./in.cue:2:9
      //     ./in.cue:2:17
    }
  }
  fatalChild: (_|_){
    // [eval]
    #b: (#struct){
    }
    x: (_|_){
      // [eval]
      a: (_|_){
        // [eval] fatalChild.x.a: undefined field: c:
        //     ./in.cue:8:17
      }
    }
  }
  okIncompleteChild: (struct){
    b: (struct){
    }
    x: (struct){
      a: (_|_){
        // [incomplete] okIncompleteChild.x.a: undefined field: c:
        //     ./in.cue:16:16
      }
      b: (int){ 1 }
    }
  }
  andInPattern: (struct){
    out: (struct){
      someKey: (struct){
      }
    }
    #constraints: (#list){
      0: (string){ =~"^.*$" }
    }
  }
}
-- out/compile --
--- in.cue
{
  fatalArg: {
    x: len(("eee" + 'eee'))
  }
  fatalChild: {
    #b: {}
    x: and([
      {
        a: 〈2;#b〉.c
      },
    ])
  }
  okIncompleteChild: {
    b: {}
    x: and([
      {
        a: 〈2;b〉.c
      },
      {
        b: 1
      },
    ])
  }
}
--- issue3412.cue
{
  andInPattern: {
    out: {
      [and(〈1;#constraints〉)]: _
      someKey: {}
    }
    #constraints: [
      =~"^.*$",
    ]
  }
}
