Properly check param/argument matching (oops)
authorJordan Rose <jrose@belkadan.com>
Tue, 20 May 2025 03:53:42 +0000 (20:53 -0700)
committerJordan Rose <jrose@belkadan.com>
Tue, 20 May 2025 03:53:42 +0000 (20:53 -0700)
scheme.py

index 82764d271fc45392f0a27412d8b1326508978584..88cd2c12c5e4b0f64379c6f3338d3ecd476eb125 100644 (file)
--- a/scheme.py
+++ b/scheme.py
@@ -126,11 +126,15 @@ class Frame:
         while formals != nil:
             if not isinstance(formals, Pair):
                 frame.bindings[formals] = vals
-                vals = None
+                vals = nil
                 break
+            if vals is nil:
+                raise SchemeError("not enough arguments in function call")
             frame.bindings[formals.first] = vals.first
             formals = formals.second
             vals = vals.second
+        if vals != nil:
+            raise SchemeError("too many arguments in function call")
         return frame
 
     def define(self, sym, val):