about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-12 10:17:46 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-12 10:17:46 -0700
commit3245570bc74382aabd1d84b5fae7cae91849df4d (patch)
treed0f4c5411b879a9c580aae6e73c2ccd4017a6297
parent29bb9841e5bc2d6ade572f21ec3f5a7a3d8e82c1 (diff)
downloadmu-3245570bc74382aabd1d84b5fae7cae91849df4d.tar.gz
133 - handle missing args without error
-rw-r--r--mu.arc3
-rw-r--r--mu.arc.t16
2 files changed, 17 insertions, 2 deletions
diff --git a/mu.arc b/mu.arc
index f202a3a3..6b33d19a 100644
--- a/mu.arc
+++ b/mu.arc
@@ -397,7 +397,8 @@
                              (do1 caller-arg-idx.context
                                 (++ caller-arg-idx.context)))
                     (trace "arg" arg " " idx " " caller-args.context)
-                    (m caller-args.context.idx))
+                    (if (len> caller-args.context idx)
+                      (m caller-args.context.idx)))
                 type
                   (ty (caller-args.context arg.0))
                 otype
diff --git a/mu.arc.t b/mu.arc.t
index a4077c7a..814a9417 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -776,7 +776,21 @@
   (prn "F - 'arg' with index can access function call arguments out of order"))
 ;? (quit)
 
-; todo: test that too few args throws an error
+(reset)
+(new-trace "new-fn-arg-missing")
+(add-fns
+  '((test1
+      ((4 integer) <- arg)
+      ((5 integer) <- arg))
+    (main
+      (test1 (1 literal))
+    )))
+(run 'main)
+;? (prn memory*)
+(if (~iso memory* (obj 4 1))
+  (prn "F - missing 'arg' doesn't cause error"))
+;? (quit)
+
 ; how should errors be handled? will be unclear until we support concurrency and routine trees.
 
 (reset)