git » jacl.git » commit 48ef9b1

Fix %LET

author Alan Dipert
2021-07-30 05:42:00 UTC
committer Alan Dipert
2021-07-30 05:42:00 UTC
parent 700cfe26357236b35a4c29ff1669b8e640a9ccce

Fix %LET

jacl.js +8 -3

diff --git a/jacl.js b/jacl.js
index c8395fd..5023167 100644
--- a/jacl.js
+++ b/jacl.js
@@ -1472,10 +1472,15 @@ const analyzeSpecials = new Map([
     node.envId = env.counter();
     node.specials = [];
     for (const binding of List.toArray(bindings)) {
-      if (!List.isProperList(binding) || List.length(binding) > 2)
+      if (!List.isProperList(binding) || !List.length || (List.length(binding) > 2))
         throw new Error(`Improper %LET binding`);
-      const [name, expr] = binding,
-            val = analyze(env.withContext('expr'), node, expr || null);
+      let name = binding.car, expr;
+      if (List.length(binding) === 1) {
+        expr = null;
+      } else {
+        expr = binding.cdr.car;
+      }
+      const val = analyze(env.withContext('expr'), node, expr);
       if (name.isSpecial) {
         node.specials.push([name, val]);
       } else {