Bend/tests/snapshots/mutual_recursion__merged.bend.snap

35 lines
1.5 KiB
Plaintext
Raw Normal View History

---
source: tests/golden_tests.rs
input_file: tests/golden_tests/mutual_recursion/merged.bend
---
Errors:
The following functions contain recursive cycles incompatible with HVM's strict evaluation:
* Rec -> X -> Rec
* Rec -> Y -> Rec
* Rec2 -> X -> Rec2
* Rec2 -> Y -> Rec2
The greedy eager evaluation of HVM may cause infinite loops.
Refactor these functions to use lazy references instead of direct function calls.
A reference is strict when it's being called ('(Foo x)') or when it's used non-linearly ('let x = Foo; (x x)').
It is lazy when it's an argument ('(x Foo)') or when it's used linearly ('let x = Foo; (x 0)').
Try one of these strategies:
- Use pattern matching with 'match', 'fold', and 'bend' to automatically lift expressions to lazy references.
- Replace direct calls with combinators. For example, change:
'Foo = λa λb (b (λc (Foo a c)) a)'
to:
'Foo = λa λb (b (λc λa (Foo a c)) (λa a) a)'
which is lifted to:
'Foo = λa λb (b Foo__C1 Foo__C2 a)'
- Replace non-linear 'let' expressions with 'use' expressions. For example, change:
'Foo = λf let x = Foo; (f x x)'
to:
'Foo = λf use x = Foo; (f x x)'
which inlines to:
'Foo = λf (f Foo Foo)'
- If disabled, re-enable the default 'float-combinators' and 'linearize-matches' compiler options.
For more information, visit: https://github.com/HigherOrderCO/Bend/blob/main/docs/lazy-definitions.md.
To disable this check, use the "-Arecursion-cycle" compiler option.