Skip to content

Commit 420aa5e

Browse files
committed
add a check to avoid infinite loop if someone builds a recursive function with const arguments
1 parent 779ee07 commit 420aa5e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

crates/lean_compiler/src/a_simplify_lang.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,8 +1656,11 @@ fn handle_const_arguments(program: &mut Program) {
16561656

16571657
// Process newly created const functions recursively until no more changes
16581658
let mut changed = true;
1659+
let mut const_depth = 0;
16591660
while changed {
16601661
changed = false;
1662+
const_depth += 1;
1663+
assert!(const_depth < 100, "Too many levels of constant arguments");
16611664
let mut additional_functions = BTreeMap::new();
16621665

16631666
// Collect all function names to process

0 commit comments

Comments
 (0)