From 2fea9777d698ac0a8a4c6b103d35aa57bcc1ad8a Mon Sep 17 00:00:00 2001 From: PaddiM8 Date: Thu, 20 Jul 2023 00:34:04 +0200 Subject: [PATCH] Fix `f(x) = x^x` not working, closing #117 --- kalk/src/analysis.rs | 5 ++++- tests/basics.kalker | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kalk/src/analysis.rs b/kalk/src/analysis.rs index f2ccfa0..c23db08 100644 --- a/kalk/src/analysis.rs +++ b/kalk/src/analysis.rs @@ -315,7 +315,10 @@ fn analyse_binary( Identifier::from_full_name("transpose"), vec![analyse_expr(context, left)?], )), - (Expr::Var(identifier), right) => analyse_var(context, identifier, None, Some(right)), + (Expr::Var(identifier), right) => { + let right = analyse_expr(context, right)?; + analyse_var(context, identifier, None, Some(right)) + }, (left, right) => Ok(Expr::Binary( Box::new(analyse_expr(context, left)?), TokenKind::Power, diff --git a/tests/basics.kalker b/tests/basics.kalker index a2d5452..24bd943 100644 --- a/tests/basics.kalker +++ b/tests/basics.kalker @@ -1,5 +1,7 @@ x = 2 y = 3 f(x) = 2x(x - 3)(y + 2) +g(x) = x^x -2f(f(x) + y) * 2 = 13600 \ No newline at end of file +2f(f(x) + y) * 2 = 13600 and +g(2) = 4