Commit d98b42b981e9f338cee37f39ae25bc5335df9a10

Thomas de Grivel 2024-03-07T14:40:47

wip segv ic3> (Complex) 0

diff --git a/.ic3_history b/.ic3_history
index e4a64a5..d1039fb 100644
--- a/.ic3_history
+++ b/.ic3_history
@@ -1,9 +1,3 @@
-1/2 + 1/3
-1/2 + 2/3
-3/2 + 1/3
-3/2 + 2/3
-4/2 + 2/3
-4/2 / 2/3
 1/2 / 2/3
 1/2 * 2/3
 1/2 - 2/3
@@ -97,3 +91,9 @@ 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)
diff --git a/lib/c3/0.1/var.facts b/lib/c3/0.1/var.facts
new file mode 100644
index 0000000..7b74bd2
--- /dev/null
+++ b/lib/c3/0.1/var.facts
@@ -0,0 +1,3 @@
+%{module: C3.Facts.Dump,
+  version: 1}
+replace {Var, :is_a, :module}
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 8e4be43..780e2d8 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -3461,7 +3461,8 @@ sw buf_parse_tag_primary (s_buf *buf, s_tag *dest)
       goto restore;
     result += r;
   }
-  if ((r = buf_parse_tag_void(buf, dest)) != 0 ||
+  if ((r = buf_parse_tag_var(buf, dest)) != 0 ||
+      (r = buf_parse_tag_void(buf, dest)) != 0 ||
       (r = buf_parse_tag_number(buf, dest)) != 0 ||
       (r = buf_parse_tag_number(buf, dest)) != 0 ||
       (r = buf_parse_tag_ratio(buf, dest)) != 0 ||
@@ -3585,6 +3586,16 @@ sw buf_parse_tag_unquote (s_buf *buf, s_tag *dest)
   return r;
 }
 
+sw buf_parse_tag_var (s_buf *buf, s_tag *dest)
+{
+  sw r;
+  assert(buf);
+  assert(dest);
+  if ((r = buf_parse_var(buf, NULL)) > 0)
+    dest->type = TAG_VAR;
+  return r;
+}
+
 sw buf_parse_tag_void (s_buf *buf, s_tag *dest)
 {
   sw r;
@@ -3774,6 +3785,7 @@ sw buf_parse_var (s_buf *buf, void *dest)
     r = 0;
     goto restore;
   }
+  goto clean;
  restore:
   buf_save_restore_rpos(buf, &save);
  clean:
diff --git a/libc3/buf_parse.h b/libc3/buf_parse.h
index cb8575e..299bde8 100644
--- a/libc3/buf_parse.h
+++ b/libc3/buf_parse.h
@@ -130,6 +130,7 @@ sw buf_parse_tag_struct (s_buf *buf, s_tag *dest);
 sw buf_parse_tag_sym (s_buf *buf, s_tag *dest);
 sw buf_parse_tag_tuple (s_buf *buf, s_tag *dest);
 sw buf_parse_tag_unquote (s_buf *buf, s_tag *dest);
+sw buf_parse_tag_var (s_buf *buf, s_tag *dest);
 sw buf_parse_tag_void (s_buf *buf, s_tag *dest);
 sw buf_parse_tuple (s_buf *buf, s_tuple *dest);
 sw buf_parse_u64_hex (s_buf *buf, u64 *dest);
diff --git a/libc3/sym.c b/libc3/sym.c
index a2fd14d..eeb81d9 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -551,6 +551,10 @@ bool sym_must_clean (const s_sym *sym, bool *must_clean)
     *must_clean = false;
     return true;
   }
+  if (sym == &g_sym_Var) {
+    *must_clean = false;
+    return true;
+  }
   if (sym == &g_sym_Void) {
     *must_clean = false;
     return true;