mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-09-11 11:56:54 +03:00
33 lines
1.4 KiB
Plaintext
33 lines
1.4 KiB
Plaintext
---
|
||
source: tests/golden_tests.rs
|
||
input_file: tests/golden_tests/compile_file_o_no_all/sum_tree.bend
|
||
---
|
||
[4m[1m[31mErrors:[0m
|
||
[1mThe following functions contain recursive cycles incompatible with HVM's strict evaluation:[0m
|
||
* gen -> gen
|
||
* sum -> sum
|
||
|
||
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)').
|
||
|
||
[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:
|
||
'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.
|