From 9501dea85ad2dd6fcd9f30ff4debd83f5a684ded Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Sun, 13 Oct 2024 21:57:21 +0100 Subject: [PATCH] Temporarily revert the support for redefining variables in the body The current implementation appears to be buggy. Need to investigage how to do it properly. --- src/compiler.cpp | 2 +- test/function.vli | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/compiler.cpp b/src/compiler.cpp index 602469c..87b0973 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -951,7 +951,7 @@ Result Compiler::compile_body(Context& context, const Value& expr) { ex_res.reg = expr.reg; } else { // TODO: commenting this out means we waste registers - // context.maxreg = maxreg; + context.maxreg = maxreg; } } diff --git a/test/function.vli b/test/function.vli index 8716147..f71ddc5 100644 --- a/test/function.vli +++ b/test/function.vli @@ -56,22 +56,22 @@ (assert (= (do 1 2 3) 3)) -;; allow definition and redefinition of variables with "def" +;; ;; allow definition and redefinition of variables with "def" -(fn def-redef () - (def x 1) - (def x (+ x 1)) - (def y 4) - (+ x y)) +;; (fn def-redef () +;; (def x 1) +;; (def x (+ x 1)) +;; (def y 4) +;; (+ x y)) -(assert (= (def-redef) 6)) +;; (assert (= (def-redef) 6)) -;; allow redefenition of variables with "fn" +;; ;; allow redefenition of variables with "fn" -(fn def-redef-fn () - (def x 2) - (fn x (y) (+ x y)) - (x 3) - ) +;; (fn def-redef-fn () +;; (def x 2) +;; (fn x (y) (+ x y)) +;; (x 3) +;; ) -(assert (= (def-redef-fn) 5)) +;; (assert (= (def-redef-fn) 5))