Commit 22c8c6f03f83b8e2c78c333c0851f6b0e14af727

Thomas de Grivel 2024-02-16T14:30:02

fix macro

diff --git a/ic3/.ic3_history b/ic3/.ic3_history
index 81326ad..be4a069 100644
--- a/ic3/.ic3_history
+++ b/ic3/.ic3_history
@@ -1,9 +1,3 @@
-dlopen("libc3/window/.libs/libc3_window.so.0.0", (U32) 16)
-dlopen("libc3/window/.libs/libc3_window.so.0.0", (U32) 32)
-dlopen("libc3/window/.libs/libc3_window.so.0.0", (U32) 0)
-dlopen("/home/dx/c/thodg/c3-lang/c3/libc3/window/.libs/libc3_window.so.0.0", (U32) 0)
-getenv("_")
-getenv("SHELL")
 getenv("HOME")
 getenv("USER")
 "a" + "b"
@@ -97,3 +91,9 @@ name = "Plop"
 ^ name = "Plop"
 ^ name = plop
 plop
+n = "Plop"
+m = macro (name) { quote "Hello, " + (unquote name) + " !" }
+m(n)
+n = "Plop"
+m = macro (name) { quote "Hello, " + (unquote name) + " !" }
+m(n)
diff --git a/libc3/env.c b/libc3/env.c
index c821ba7..1ecc0b4 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -404,12 +404,18 @@ bool env_eval_equal_tag (s_env *env, bool macro, const s_tag *a,
     return false;
   }
   if (is_unbound_a) {
-    env_eval_tag(env, b, dest);
+    if (macro)
+      tag_init_copy(dest, b);
+    else
+      env_eval_tag(env, b, dest);
     frame_binding_new(env->frame, a->data.ident.sym, dest);
     return true;
   }
   if (is_unbound_b) {
-    env_eval_tag(env, a, dest);
+    if (macro)
+      tag_init_copy(dest, a);
+    else
+      env_eval_tag(env, a, dest);
     frame_binding_new(env->frame, b->data.ident.sym, dest);
     return true;
   }
@@ -595,7 +601,7 @@ bool env_eval_fn_call (s_env *env, const s_fn *fn,
       clause = clause->next_clause;
     }
     if (! clause) {
-      err_puts("env_eval_call_fn: no clause matching.\nTried clauses :\n");
+      err_puts("env_eval_fn_call: no clause matching.\nTried clauses :\n");
       clause = fn->clauses;
       while (clause) {
         err_inspect_fn_pattern(clause->pattern);