# Tests that mutually recursive optional definitions across packages do not cause
# the evaluator to hang. Issue: a pattern constraint referencing a type from an
# imported package, where that type and its transitive references form a cycle
# (e.g. #Foo -> #Bar -> #Foo), caused an infinite loop during evaluation.
# https://cuelang.org/issue/3709
-- cue.mod/module.cue --
module: "foo.test/bar"
language: version: "v0.11.0"
-- input.cue --
package p

import "foo.test/bar/imported"

out: [string]: imported.#Foo
@test(eq, { out: [string]: {bar?: foo?: _ @test(ignore)} })
-- imported/imported.cue --
package imported

#Foo: bar?: #Bar
#Bar: foo?: #Foo
-- out/eval/stats --
Leaks:  0
Freed:  2
Reused: 0
Allocs: 2
Retain: 0

Unifications: 2
Conjuncts:    2
Disjuncts:    2
