about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--mu.arc8
-rw-r--r--mu.arc.t27
2 files changed, 33 insertions, 2 deletions
diff --git a/mu.arc b/mu.arc
index aaab580a..1e99adab 100644
--- a/mu.arc
+++ b/mu.arc
@@ -1067,11 +1067,15 @@
   (each (op . rest)  forms
     (case op
       ; syntax: def <name> [ <instructions> ]
-      def
+      ; don't apply our lightweight tools just yet
+      def!
         (let (name (_make-br-fn body))  rest
           (assert (is 'make-br-fn _make-br-fn))
-          ; don't apply our lightweight tools just yet
           (= function*.name body))
+      def
+        (let (name (_make-br-fn body))  rest
+          (assert (is 'make-br-fn _make-br-fn))
+          (= function*.name (join body function*.name)))
 
       ; syntax: before <label> [ <instructions> ]
       ;
diff --git a/mu.arc.t b/mu.arc.t
index caace661..8534e9f4 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -2807,4 +2807,31 @@
             ((1 integer) <- copy (0 literal))))
   (prn "F - before/after can come after the function they need to modify"))
 
+(reset)
+(new-trace "multiple-defs")
+(add-code '((def f1 [
+              ((1 integer) <- copy (0 literal))
+             ])
+            (def f1 [
+              ((2 integer) <- copy (0 literal))
+             ])))
+(freeze-functions)
+(if (~iso function*!f1
+          '(((2 integer) <- copy (0 literal))
+            ((1 integer) <- copy (0 literal))))
+  (prn "F - multiple 'def' of the same function add clauses"))
+
+(reset)
+(new-trace "def!")
+(add-code '((def f1 [
+              ((1 integer) <- copy (0 literal))
+             ])
+            (def! f1 [
+              ((2 integer) <- copy (0 literal))
+             ])))
+(freeze-functions)
+(if (~iso function*!f1
+          '(((2 integer) <- copy (0 literal))))
+  (prn "F - 'def!' clears all previous clauses"))
+
 (reset)  ; end file with this to persist the trace for the final test