From 1dd0377e313ac65223028aa71847c670ff90a9a9 Mon Sep 17 00:00:00 2001 From: bakk Date: Sun, 16 Jan 2022 21:58:46 +0100 Subject: [PATCH] Allow nested integrals --- kalk/src/analysis.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kalk/src/analysis.rs b/kalk/src/analysis.rs index edfd7d2..fd3e465 100644 --- a/kalk/src/analysis.rs +++ b/kalk/src/analysis.rs @@ -597,10 +597,12 @@ fn build_fn_call( log_base: Option, ) -> Result { let is_integral = identifier.pure_name == "integrate"; + let prev_in_integral = context.in_integral; if is_integral { context.in_integral = true; } + let prev_in_sum_prod = context.in_sum_prod; let is_sum_prod = identifier.pure_name == "sum" || identifier.pure_name == "prod"; if is_sum_prod { context.in_sum_prod = true; @@ -652,11 +654,11 @@ fn build_fn_call( }; if is_integral { - context.in_integral = false; + context.in_integral = prev_in_integral; } if is_sum_prod { - context.in_sum_prod = false; + context.in_sum_prod = prev_in_sum_prod; } Ok(Expr::FnCall(identifier, arguments))