about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-12 10:49:08 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-12 10:49:33 -0700
commit244f31f7ee9b9d9114683b36636b6563cb08be6b (patch)
tree33f9d88dd5c8a5dccd6a5b0bb2a5e28fa8b04cb4
parentaa7de0e8afb518cc4d42561945b3a6ece87a45f2 (diff)
downloadmu-244f31f7ee9b9d9114683b36636b6563cb08be6b.tar.gz
137
-rw-r--r--mu.arc4
-rw-r--r--mu.arc.t41
2 files changed, 40 insertions, 5 deletions
diff --git a/mu.arc b/mu.arc
index 57e86835..6545fc59 100644
--- a/mu.arc
+++ b/mu.arc
@@ -398,8 +398,8 @@
                                 (++ caller-arg-idx.context)))
                     (trace "arg" arg " " idx " " caller-args.context)
                     (if (len> caller-args.context idx)
-                      (list (m caller-args.context.idx) nil)
-                      (list nil t)))
+                      (list (m caller-args.context.idx) t)
+                      (list nil nil)))
                 type
                   (ty (caller-args.context arg.0))
                 otype
diff --git a/mu.arc.t b/mu.arc.t
index a9afb940..4d7df707 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -777,6 +777,20 @@
 ;? (quit)
 
 (reset)
+(new-trace "new-fn-arg-status")
+(add-fns
+  '((test1
+      ((4 integer) (5 boolean) <- arg))
+    (main
+      (test1 (1 literal))
+    )))
+(run 'main)
+;? (prn memory*)
+(if (~iso memory* (obj 4 1  5 t))
+  (prn "F - 'arg' sets a second oarg when arg exists"))
+;? (quit)
+
+(reset)
 (new-trace "new-fn-arg-missing")
 (add-fns
   '((test1
@@ -802,8 +816,8 @@
     )))
 (run 'main)
 ;? (prn memory*)
-(if (~iso memory* (obj 4 1  6 t))
-  (prn "F - missing 'arg' sets a second oarg when provided"))
+(if (~iso memory* (obj 4 1  6 nil))
+  (prn "F - missing 'arg' wipes second oarg when provided"))
 ;? (quit)
 
 (reset)
@@ -818,10 +832,31 @@
     )))
 (run 'main)
 ;? (prn memory*)
-(if (~iso memory* (obj 4 1  6 t))
+(if (~iso memory* (obj 4 1  6 nil))
   (prn "F - missing 'arg' consistently wipes its oarg"))
 ;? (quit)
 
+(reset)
+(new-trace "new-fn-arg-missing-3")
+(add-fns
+  '((test1
+      ; if given two args, adds them; if given one arg, increments
+      ((4 integer) <- arg)
+      ((5 integer) (6 boolean) <- arg)
+      { begin
+        (breakif (6 boolean))
+        ((5 integer) <- copy (1 literal))
+      }
+      ((7 integer) <- add (4 integer) (5 integer)))
+    (main
+      (test1 (34 literal))
+    )))
+(run 'main)
+;? (prn memory*)
+(if (~iso memory* (obj 4 34  5 1  6 nil  7 35))
+  (prn "F - function with optional second arg"))
+;? (quit)
+
 ; how should errors be handled? will be unclear until we support concurrency and routine trees.
 
 (reset)