#name: reentrance
#evalFull
-- in.cue --
// This indirection is needed to avoid binding references to fib
// within fib to the instantiated version.
fibRec: {
	nn:  int
	out: (fib & {n: nn}).out
	@test(err, code=incomplete, at=out)
}
fib: {
	n: int

	if n >= 2 {
		out: (fibRec & {nn: n - 2}).out + (fibRec & {nn: n - 1}).out
	}
	if n < 2 {
		out: n
	}
	@test(err, code=incomplete)
}
fib1:  (fib & {n: 1}).out  @test(eq, 1) // MAY NOT be an error
fib2:  (fib & {n: 2}).out  @test(eq, 1) // MAY be an error
fib3:  (fib & {n: 3}).out  @test(err, code=structural_cycle) // SHOULD be an error
fib7:  (fib & {n: 7}).out  @test(err, code=structural_cycle) // Error
fib12: (fib & {n: 12}).out @test(err, code=structural_cycle) // Error

-- out/errors.txt --
[incomplete] non-concrete value int in operand to >=:
    ./in.cue:11:5
    ./in.cue:5:18
    ./in.cue:9:5
non-concrete value int in operand to <:
    ./in.cue:14:5
    ./in.cue:5:18
    ./in.cue:9:5
[incomplete] fib: non-concrete value int in operand to >=:
    ./in.cue:11:5
    ./in.cue:9:5
fib: non-concrete value int in operand to <:
    ./in.cue:14:5
    ./in.cue:9:5
[structural_cycle] structural cycle:
    ./in.cue:5:8
[structural_cycle] structural cycle:
    ./in.cue:5:8
structural cycle:
    ./in.cue:12:9
structural cycle:
    ./in.cue:12:38
[structural_cycle] structural cycle:
    ./in.cue:5:8
structural cycle:
    ./in.cue:12:9
structural cycle:
    ./in.cue:12:38
-- out/todo.txt --
Structural cycle error positions differ between v2 and v3: v2 includes an
extra structural cycle at ./in.cue:3:25 (fibRec reference) for fib3/fib7/fib12;
v3 reports positions at in.cue:8:9 and in.cue:8:38 only. Functionally both
versions correctly report fib1=1, fib2=1, and fib3/fib7/fib12 as errors.
-- out/eval/stats --
Leaks:  14
Freed:  135
Reused: 112
Allocs: 37
Retain: 0

Unifications: 131
Conjuncts:    341
Disjuncts:    0

NumCloseIDs: 137
