# CUE hangs indefinitely when a structural cycle reference is wrapped in braces
# before a field selector, e.g. `a: b: c: {a}.b`. Without braces (`a: b: c:
# a.b`) the cycle is correctly detected and reported as an error. The braces
# prevent cycle detection, causing CUE to loop forever instead of reporting an
# error. Affects all variants: `{a & _}.b`, `{a.b}.c`, nested structs, etc.
# https://cuelang.org/issue/4210
-- in.cue --
t1: {
	a: b: c: {a}.b
	@test(err, code=structural_cycle, contains="structural cycle", pos=[])
}
t2: {
	a: b: c: {a & _}.b
	@test(err, code=structural_cycle, contains="structural cycle", pos=[])
}
t3: {
	a: b: c: d: {a.b}.c
	@test(err, code=structural_cycle, contains="structural cycle", pos=[])
}
t4: {
	x: y: z: {a}.y
	a: x
	@test(err, code=structural_cycle, contains="structural cycle", pos=[])
}
-- out/errors.txt --
[structural_cycle] t1.a.b.c.c: structural cycle
[structural_cycle] t2.a.b.c.c: structural cycle
[structural_cycle] t3.a.b.c.d.d: structural cycle
[structural_cycle] t4.x.y.z.z: structural cycle
-- out/eval/stats --
Leaks:  0
Freed:  39
Reused: 25
Allocs: 14
Retain: 0

Unifications: 31
Conjuncts:    55
Disjuncts:    0

NumCloseIDs: 30
