-- in.cue --
import "encoding/yaml"

// Defaults don't resolve struct values; a default that selects a missing
// field in a struct should fall back to the other disjunct.
// https://cuelang.org/issue/700
issue700: {
	a: y: "y"
	test1: *a.x | 1
	test2: *a.y | 1
}

lookup: {
	x: {
		name: "Hello"
	}
	y:        x.a
	ok1:      *x.a | x
	ok2:      x | *x.a
	ok3:      x.a | *x
	ok4:      *x | x.a
	ok5:      x | x.a
	ok5:      x.a | x
	allFail1: x.a | x.b
	allFail2: x.a | x.b
}

func: {
	s:   string
	ok1: yaml.MarshalStream(s) | yaml.Marshal(s)
}

// Default mark on interpolated string; a concrete override should suppress
// a default interpolation regardless of whether it is left or right in the disjunction.
// https://cuelang.org/issue/782
issue782: {
	a: {
		inner:         string
		interpolation: *"\(inner)" | string
		interpolation: "override"
	}
	b: {
		inner:         string
		interpolation: string | *"\(inner)"
		interpolation: "override"
	}
	c: {
		inner:         string
		interpolation: "\(inner)" | string
		interpolation: "override"
	}
	d: {
		inner:         string
		interpolation: string | "\(inner)"
		interpolation: "override"
	}
}
-- issue3680.cue --
// evalv3: "unexpected uninitialized node" regression with bottom optional fields;
// optional fields set to _|_ in a disjunct should not cause a crash.
// https://cuelang.org/issue/3680
issue3680: t1: {
	{} | {
		a?: _|_
		b?: _|_
	}
	{} | {}
}
issue3680: t2: {
	x: {} | {
		a?: _|_
		b?: _|_
	}
	x: {} | {}
}
-- out/compile --
--- in.cue
{
  issue700: {
    a: {
      y: "y"
    }
    test1: (*〈0;a〉.x|1)
    test2: (*〈0;a〉.y|1)
  }
  lookup: {
    x: {
      name: "Hello"
    }
    y: 〈0;x〉.a
    ok1: (*〈0;x〉.a|〈0;x〉)
    ok2: (〈0;x〉|*〈0;x〉.a)
    ok3: (〈0;x〉.a|*〈0;x〉)
    ok4: (*〈0;x〉|〈0;x〉.a)
    ok5: (〈0;x〉|〈0;x〉.a)
    ok5: (〈0;x〉.a|〈0;x〉)
    allFail1: (〈0;x〉.a|〈0;x〉.b)
    allFail2: (〈0;x〉.a|〈0;x〉.b)
  }
  func: {
    s: string
    ok1: (〈import;"encoding/yaml"〉.MarshalStream(〈0;s〉)|〈import;"encoding/yaml"〉.Marshal(〈0;s〉))
  }
  issue782: {
    a: {
      inner: string
      interpolation: (*"\(〈0;inner〉)"|string)
      interpolation: "override"
    }
    b: {
      inner: string
      interpolation: (string|*"\(〈0;inner〉)")
      interpolation: "override"
    }
    c: {
      inner: string
      interpolation: ("\(〈0;inner〉)"|string)
      interpolation: "override"
    }
    d: {
      inner: string
      interpolation: (string|"\(〈0;inner〉)")
      interpolation: "override"
    }
  }
}
--- issue3680.cue
{
  issue3680: {
    t1: {
      ({}|{
        a?: _|_(explicit error (_|_ literal) in source)
        b?: _|_(explicit error (_|_ literal) in source)
      })
      ({}|{})
    }
  }
  issue3680: {
    t2: {
      x: ({}|{
        a?: _|_(explicit error (_|_ literal) in source)
        b?: _|_(explicit error (_|_ literal) in source)
      })
      x: ({}|{})
    }
  }
}
