diff options
author | Case Duckworth | 2024-03-31 22:14:31 -0500 |
---|---|---|
committer | Case Duckworth | 2024-03-31 22:14:31 -0500 |
commit | 877fca875a92c01089ca0697e1aeecb1ff37708e (patch) | |
tree | ca2d4e3f2e8c369cb464c0ea4fe71197e34693a5 | |
parent | Add quasiquote (diff) | |
download | lam-877fca875a92c01089ca0697e1aeecb1ff37708e.tar.gz lam-877fca875a92c01089ca0697e1aeecb1ff37708e.zip |
Error on unbound variables
I still need to catch errors!
-rw-r--r-- | eval.lua | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/eval.lua b/eval.lua index 714c67e..2e3a2bf 100644 --- a/eval.lua +++ b/eval.lua | |||
@@ -103,6 +103,9 @@ m.specials.def = m.specials.define | |||
103 | function m.eval (x, env) | 103 | function m.eval (x, env) |
104 | local env = env or core.env | 104 | local env = env or core.env |
105 | if type.isa(x, "symbol") then | 105 | if type.isa(x, "symbol") then |
106 | if env[x] == nil then | ||
107 | error(string.format("Unbound variable: %s", x)) | ||
108 | end | ||
106 | return env[x] | 109 | return env[x] |
107 | elseif not type.islist(x) then | 110 | elseif not type.islist(x) then |
108 | return x | 111 | return x |