// Issue 4055: crash variant
// Issue 4056
-- issue4056.cue --
import "strings"

// cmd/cue: "unresolved disjunction" when error() disjuncts are added inside
// a conditional that depends on the same field; the concrete value should win.
// https://cuelang.org/issue/4056
issue4056: full: {
	a: "foo-bar"
	a: _ | error("error message 1")
	if strings.HasPrefix(a, "foo") {
		a: _ | error("error message 2")
	}
}
issue4056: reduced: {
	a: "x"
	a: _ | error("a")
	if len(a) > 0 {
		a: _ | error("b")
	}
}
variant: {
	a: "x"
	a: string | int
	if len(a) > 0 {
		a: _
	}
}
-- pending.cue --
// Be sure to emit errors for uncompleted pending arcs.
err: {
	A: "forty two"
	if A < 100 {B: true}
}
-- out/compile --
--- issue4056.cue
{
  issue4056: {
    full: {
      a: "foo-bar"
      a: (_|error("error message 1"))
      if 〈import;strings〉.HasPrefix(〈0;a〉, "foo") {
        a: (_|error("error message 2"))
      }
    }
  }
  issue4056: {
    reduced: {
      a: "x"
      a: (_|error("a"))
      if (len(〈0;a〉) > 0) {
        a: (_|error("b"))
      }
    }
  }
  variant: {
    a: "x"
    a: (string|int)
    if (len(〈0;a〉) > 0) {
      a: _
    }
  }
}
--- pending.cue
{
  err: {
    A: "forty two"
    if (〈0;A〉 < 100) {
      B: true
    }
  }
}
