From 5ecd9e1a1a4de54b2257329eb02dab11b3149424 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 8 Jul 2014 14:34:56 +0200 Subject: [PATCH] Evaluate assert --- Nix/Eval.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Nix/Eval.hs b/Nix/Eval.hs index 80740fa..a9d69b8 100644 --- a/Nix/Eval.hs +++ b/Nix/Eval.hs @@ -64,7 +64,13 @@ evalExpr = cata phi _ -> error "scope must be a set in with statement" _ -> error "invalid evaluation environment" - phi (NAssert _e _v) = error "assert: not implemented" + phi (NAssert cond e) = \env -> do + (Fix cond') <- cond env + case cond' of + (NVConstant (NBool True)) -> e env + (NVConstant (NBool False)) -> error "assertion failed" + _ -> error "assertion condition must be boolean" + phi (NVar _v) = error "var: not implemented" phi (NApp fun x) = \env -> do