# Tests that a disjunction inside a definition resolves correctly when a
# discriminant field is set. After unifying #Task with {op: "pull"}, the
# "pull" branch is selected and expressions using the defaulted tag
# field (tag: *"latest" | string) evaluate concretely.
#evalFull
-- in.cue --
#Task: {
	{
		op:          "pull"
		tag:         *"latest" | string
		refToTag:    tag
		tagExpr:     tag + "dd"
		tagInString: "\(tag)"
	} | {
		op: "scratch"
	}
}

foo: #Task & {"op": "pull"}
-- out/compile --
--- in.cue
{
  #Task: {
    ({
      op: "pull"
      tag: (*"latest"|string)
      refToTag: 〈0;tag〉
      tagExpr: (〈0;tag〉 + "dd")
      tagInString: "\(〈0;tag〉)"
    }|{
      op: "scratch"
    })
  }
  foo: (〈0;#Task〉 & {
    op: "pull"
  })
}
