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.
This commit is contained in:
Konstantin Nazarov 2024-10-13 21:57:21 +01:00
parent 5f2636c62f
commit 9501dea85a
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
2 changed files with 15 additions and 15 deletions

View file

@ -951,7 +951,7 @@ Result<Expression> 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;
}
}

View file

@ -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))