about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-12 10:23:02 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-12 10:23:02 -0700
commit89ee18a13effc454fbb4accb094119d5d3398a29 (patch)
treeb5139165a7dfd9b52900bc977cd27ca4318b60ab
parent3245570bc74382aabd1d84b5fae7cae91849df4d (diff)
downloadmu-89ee18a13effc454fbb4accb094119d5d3398a29.tar.gz
134 - 'arg' explicitly tells us if an arg was found
Return values can be ignored in mu, in the grand traditions of C programming.
Though library writers can impose their conservatism on callers by returning
the error condition first.
-rw-r--r--mu.arc3
-rw-r--r--mu.arc.t15
2 files changed, 17 insertions, 1 deletions
diff --git a/mu.arc b/mu.arc
index 6b33d19a..fe64105a 100644
--- a/mu.arc
+++ b/mu.arc
@@ -398,7 +398,8 @@
                                 (++ caller-arg-idx.context)))
                     (trace "arg" arg " " idx " " caller-args.context)
                     (if (len> caller-args.context idx)
-                      (m caller-args.context.idx)))
+                      (list (m caller-args.context.idx) nil)
+                      (list nil t)))
                 type
                   (ty (caller-args.context arg.0))
                 otype
diff --git a/mu.arc.t b/mu.arc.t
index 814a9417..9c63d882 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -791,6 +791,21 @@
   (prn "F - missing 'arg' doesn't cause error"))
 ;? (quit)
 
+(reset)
+(new-trace "new-fn-arg-missing-2")
+(add-fns
+  '((test1
+      ((4 integer) <- arg)
+      ((5 integer) (6 boolean) <- arg))
+    (main
+      (test1 (1 literal))
+    )))
+(run 'main)
+;? (prn memory*)
+(if (~iso memory* (obj 4 1  6 t))
+  (prn "F - missing 'arg' sets a second oarg when provided"))
+;? (quit)
+
 ; how should errors be handled? will be unclear until we support concurrency and routine trees.
 
 (reset)