mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-09-11 03:45:29 +03:00
Update cycle error message
This commit is contained in:
parent
16b5743d77
commit
4645b3231b
@ -36,6 +36,7 @@
|
|||||||
"interner",
|
"interner",
|
||||||
"itertools",
|
"itertools",
|
||||||
"lcons",
|
"lcons",
|
||||||
|
"linearization",
|
||||||
"linearizes",
|
"linearizes",
|
||||||
"linearizing",
|
"linearizing",
|
||||||
"lnet",
|
"lnet",
|
||||||
|
@ -40,7 +40,7 @@ This code will work as expected, because `Nat.add` is unrolled lazily only when
|
|||||||
|
|
||||||
### Automatic optimization
|
### Automatic optimization
|
||||||
|
|
||||||
HVM-lang carries out [match linearization](compiler-options#linearize-matches) and [combinator floating](compiler-options#float-combinators) optimizations, enabled through the CLI, which is active by default in strict mode.
|
HVM-lang carries out [match linearization](compiler-options#linearize-matches) and [combinator floating](compiler-options#float-combinators) optimizations, enabled through the CLI, which are active by default in strict mode.
|
||||||
|
|
||||||
Consider the code below:
|
Consider the code below:
|
||||||
|
|
||||||
|
@ -13,7 +13,17 @@ pub fn check_cycles(book: &Book) -> Result<(), String> {
|
|||||||
let graph = Graph::from(book);
|
let graph = Graph::from(book);
|
||||||
let cycles = graph.cycles();
|
let cycles = graph.cycles();
|
||||||
|
|
||||||
if cycles.is_empty() { Ok(()) } else { Err(pretty_print_cycles(&cycles)) }
|
if cycles.is_empty() {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(format!(
|
||||||
|
"{}\n{}\n{}\n{}",
|
||||||
|
"Mutual recursion cycle detected in compiled funcions:",
|
||||||
|
pretty_print_cycles(&cycles),
|
||||||
|
"This program will expand infinitely in strict evaluation mode.",
|
||||||
|
"Read https://github.com/HigherOrderCO/hvm-lang/blob/main/docs/lazy-definitions.md for more information."
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pretty_print_cycles(cycles: &[Vec<Ref>]) -> String {
|
fn pretty_print_cycles(cycles: &[Vec<Ref>]) -> String {
|
||||||
|
11
tests/golden_tests/mutual_recursion/multiple.hvm
Normal file
11
tests/golden_tests/mutual_recursion/multiple.hvm
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
(A) = (B)
|
||||||
|
(B) = (C)
|
||||||
|
(C) = (A)
|
||||||
|
|
||||||
|
(H) = (I)
|
||||||
|
(I) = (H)
|
||||||
|
|
||||||
|
(M) = (N)
|
||||||
|
(N) = (M)
|
||||||
|
|
||||||
|
(Main) = *
|
@ -2,4 +2,7 @@
|
|||||||
source: tests/golden_tests.rs
|
source: tests/golden_tests.rs
|
||||||
input_file: tests/golden_tests/mutual_recursion/a_b_c.hvm
|
input_file: tests/golden_tests/mutual_recursion/a_b_c.hvm
|
||||||
---
|
---
|
||||||
|
Mutual recursion cycle detected in compiled funcions:
|
||||||
Cycle 1: A -> B -> C
|
Cycle 1: A -> B -> C
|
||||||
|
This program will expand infinitely in strict evaluation mode.
|
||||||
|
Read https://github.com/HigherOrderCO/hvm-lang/blob/main/docs/lazy-definitions.md for more information.
|
||||||
|
10
tests/snapshots/mutual_recursion__multiple.hvm.snap
Normal file
10
tests/snapshots/mutual_recursion__multiple.hvm.snap
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
source: tests/golden_tests.rs
|
||||||
|
input_file: tests/golden_tests/mutual_recursion/multiple.hvm
|
||||||
|
---
|
||||||
|
Mutual recursion cycle detected in compiled funcions:
|
||||||
|
Cycle 1: A -> B -> C
|
||||||
|
Cycle 2: H -> I
|
||||||
|
Cycle 3: M -> N
|
||||||
|
This program will expand infinitely in strict evaluation mode.
|
||||||
|
Read https://github.com/HigherOrderCO/hvm-lang/blob/main/docs/lazy-definitions.md for more information.
|
@ -2,4 +2,7 @@
|
|||||||
source: tests/golden_tests.rs
|
source: tests/golden_tests.rs
|
||||||
input_file: tests/golden_tests/mutual_recursion/odd_even.hvm
|
input_file: tests/golden_tests/mutual_recursion/odd_even.hvm
|
||||||
---
|
---
|
||||||
|
Mutual recursion cycle detected in compiled funcions:
|
||||||
Cycle 1: isEven -> isOdd
|
Cycle 1: isEven -> isOdd
|
||||||
|
This program will expand infinitely in strict evaluation mode.
|
||||||
|
Read https://github.com/HigherOrderCO/hvm-lang/blob/main/docs/lazy-definitions.md for more information.
|
||||||
|
Loading…
Reference in New Issue
Block a user