# Tests cycles and incomplete errors. The cycle struct covers resolvable cycles
# (x=200, x=y+100, y=x-100 resolves because x is grounded at 200) and
# unresolvable ones (a=b+100, b=a-100 — cycle error). The incompleteOne and
# incompleteTwo cases verify that string interpolation with an abstract type
# parameter reports "incomplete" errors correctly regardless of whether the
# hidden template field _t appears before or after its usage site.
-- in.cue --
cycle: {
	x: 200
	x: y + 100
	y: x - 100

	a: b + 100
	b: a - 100
}

incompleteOne: {
	_t: {
		#p: string
		"""
			hello \(#p)
			"""
	}

	r: """
		\(_t)
		"""
}

incompleteTwo: {
	r: """
		\(_t)
		"""

	_t: {
		#p: string
		"""
			hello \(#p)
			"""
	}
}
-- out/compile --
--- in.cue
{
  cycle: {
    x: 200
    x: (〈0;y〉 + 100)
    y: (〈0;x〉 - 100)
    a: (〈0;b〉 + 100)
    b: (〈0;a〉 - 100)
  }
  incompleteOne: {
    _t: {
      #p: string
      "hello \(〈0;#p〉)"
    }
    r: "\(〈0;_t〉)"
  }
  incompleteTwo: {
    r: "\(〈0;_t〉)"
    _t: {
      #p: string
      "hello \(〈0;#p〉)"
    }
  }
}
