2024-03-12 16:10:43 +03:00
|
|
|
|
---
|
|
|
|
|
source: tests/golden_tests.rs
|
2024-05-15 01:25:46 +03:00
|
|
|
|
input_file: tests/golden_tests/mutual_recursion/odd_even.bend
|
2024-03-12 16:10:43 +03:00
|
|
|
|
---
|
2024-05-09 19:05:52 +03:00
|
|
|
|
[4m[1m[31mErrors:[0m
|
|
|
|
|
[1mThe following functions contain recursive cycles incompatible with HVM's strict evaluation:[0m
|
2024-03-22 16:21:48 +03:00
|
|
|
|
* isEven -> isOdd -> isEven
|
2024-03-20 22:50:22 +03:00
|
|
|
|
|
2024-05-09 19:05:52 +03:00
|
|
|
|
The greedy eager evaluation of HVM may cause infinite loops.
|
|
|
|
|
[1mRefactor these functions to use lazy references instead of direct function calls.[0m
|
|
|
|
|
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)').
|
2024-03-20 22:50:22 +03:00
|
|
|
|
|
2024-05-09 19:05:52 +03:00
|
|
|
|
[1mTry one of these strategies:[0m
|
|
|
|
|
- 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:
|
2024-05-25 20:01:11 +03:00
|
|
|
|
'Foo = λa λb (b Foo__C1 Foo__C2 a)'
|
2024-05-09 19:05:52 +03:00
|
|
|
|
- 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.
|
2024-03-20 22:50:22 +03:00
|
|
|
|
|
2024-05-25 20:01:11 +03:00
|
|
|
|
For more information, visit: https://github.com/HigherOrderCO/Bend/blob/main/docs/lazy-definitions.md.
|
2024-05-09 19:05:52 +03:00
|
|
|
|
To disable this check, use the "-Arecursion-cycle" compiler option.
|