Commit 1c4811bd6461b982ba787ecc6f59640c6e778325

Thomas de Grivel 2024-03-23T05:35:45

fix def

diff --git a/.ic3_history b/.ic3_history
index 31d0774..c327d58 100644
--- a/.ic3_history
+++ b/.ic3_history
@@ -1,15 +1,3 @@
--1/-1 + 1/1
--1/-1
--1/1
-sqrt(-1)
-sqrt(-1) * sqrt(-1)
-sqrt(-2) * sqrt(-2)
-sqrt(1)
-sqrt(2)
-sqrt(-2) * sqrt(-2)
-sqrt(-1) * sqrt(-1)
-sqrt(-1)
-sqrt(-2)
 sqrt(-1) * sqrt(-1)
 sqrt(-2) * sqrt(-2)
 1/3 +i 1/2
@@ -97,3 +85,15 @@ def a = fn (x) do x * 2 end
 a
 List.reverse
 license
+def reverse = fn (x) { List.reverse(x) }
+reverse([1, 2, 3])
+def reverse = fn (x) { [:reversed | List.reverse(x)] }
+reverse([1, 2, 3])
+def reverse = fn (x) { List.reverse(x) }
+reverse([1, 2, 3])
+def reverse = fn (x) { [:reversed | List.reverse(x)] }
+reverse([1, 2, 3])
+def reverse = fn (x) { List.reverse(x) }
+reverse([1, 2, 3])
+def reverse = fn (x) { List.reverse(x) }
+C3.reverse
diff --git a/libc3/env.c b/libc3/env.c
index f14e6f3..09aa836 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -98,8 +98,8 @@ s_tag * env_def (s_env *env, const s_call *call, s_tag *dest)
   if (! facts_add_tags(&env->facts, &tag_module, &tag_symbol,
                        &tag_ident))
     return NULL;
-  if (! facts_add_tags(&env->facts, &tag_ident, &tag_symbol_value,
-                       tag_value))
+  if (! facts_replace_tags(&env->facts, &tag_ident, &tag_symbol_value,
+                           tag_value))
     return NULL;
   tag_init_ident(dest, &tag_ident.data.ident);
   return dest;
diff --git a/test/ic3/def.in b/test/ic3/def.in
index 1319e8f..21cfd02 100644
--- a/test/ic3/def.in
+++ b/test/ic3/def.in
@@ -28,3 +28,21 @@ quote double_tuple(zero)
 double_tuple(zero)
 quote double_tuple(one_two_three)
 double_tuple(one_two_three)
+quote def reverse = fn (x) { List.reverse(x) }
+def reverse = fn (x) { List.reverse(x) }
+quote C3.reverse
+C3.reverse
+quote reverse([1, 2, 3])
+reverse([1, 2, 3])
+quote def reverse = fn (x) { [:reversed | List.reverse(x)] }
+def reverse = fn (x) { [:reversed | List.reverse(x)] }
+quote C3.reverse
+C3.reverse
+quote reverse([1, 2, 3])
+reverse([1, 2, 3])
+quote def reverse = fn (x) { List.reverse(x) }
+def reverse = fn (x) { List.reverse(x) }
+quote C3.reverse
+C3.reverse
+quote reverse([1, 2, 3])
+reverse([1, 2, 3])
diff --git a/test/ic3/def.out.expected b/test/ic3/def.out.expected
index 03a8d8a..396da43 100644
--- a/test/ic3/def.out.expected
+++ b/test/ic3/def.out.expected
@@ -28,3 +28,21 @@ double_tuple(zero)
 {0, 0}
 double_tuple(one_two_three)
 {[1, 2, 3], [1, 2, 3]}
+def reverse = fn (x) { List.reverse(x) }
+C3.reverse
+C3.reverse
+fn (x) { List.reverse(x) }
+reverse([1, 2, 3])
+[3, 2, 1]
+def reverse = fn (x) { [:reversed | List.reverse(x)] }
+C3.reverse
+C3.reverse
+fn (x) { [:reversed | List.reverse(x)] }
+reverse([1, 2, 3])
+[:reversed, 3, 2, 1]
+def reverse = fn (x) { List.reverse(x) }
+C3.reverse
+C3.reverse
+fn (x) { List.reverse(x) }
+reverse([1, 2, 3])
+[3, 2, 1]