Commit b172fd15340a27104c6dea8535681496341c46f2

Thomas de Grivel 2023-03-12T09:28:55

wip

diff --git a/lib/c3/0.1/c3.facts b/lib/c3/0.1/c3.facts
index 93c1c35..af5d265 100644
--- a/lib/c3/0.1/c3.facts
+++ b/lib/c3/0.1/c3.facts
@@ -1,6 +1,6 @@
 %{module: C3.Facts.Dump,
   version: 0x0000000000000001,
-  count: 0x000000000000000A}
+  count: 0x0000000000000016}
 {C3, :is_a, :module}
 {C3, :name, "C3"}
 {C3, :path, "c3.facts"}
@@ -28,4 +28,4 @@
  ({a, _b, _c}) { a }
  ({a, _b, _c, _d}) { a }
 }}
-%{hash: 0xC73C2E069FEA6136}
+%{hash: 0x3EE20F4AF01A22E6}
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 9605cf9..2fd7b30 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -182,15 +182,16 @@ sw buf_parse_call_op (s_buf *buf, s_call *dest)
   assert(dest);
   buf_save_init(buf, &save);
   left = tag_new();
-  if ((r = buf_parse_tag(buf, left)) <= 0)
-    goto clean;
+  if ((r = buf_parse_tag_primary(buf, left)) <= 0)
+    goto restore;
   result += r;
-  if ((r = buf_parse_call_op_rec(buf, dest, left, 0)) < 0)
+  if ((r = buf_parse_call_op_rec(buf, dest, left, 0)) <= 0)
     goto restore;
   result += r;
   r = result;
   goto clean;
  restore:
+  r = 0;
   buf_save_restore_rpos(buf, &save);
  clean:
   buf_save_clean(buf, &save);
diff --git a/libc3/env.c b/libc3/env.c
index efbd14a..8d42b70 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -437,10 +437,10 @@ s_env * env_init (s_env *env)
     assert(! "env_init: module path not found");
     err(1, "env_init: module_path not found");
   }
+  env->current_module = &env->c3_module;
   if (! module_load(&env->c3_module, sym_1("C3"), &env->facts)) {
     return NULL;
   }
-  env->current_module = &env->c3_module;
   return env;
 }
 
@@ -493,8 +493,7 @@ bool env_operator_is_right_associative (const s_env *env, s_ident *op)
   s_tag tag_operator_assoc;
   s_tag tag_right;
   assert(env);
-  assert(call);
-  assert(dest);
+  assert(op);
   ident_resolve_module(op, env);
   tag_init_ident(&tag_ident, op);
   tag_init_1(    &tag_operator_assoc, ":operator_associativity");
@@ -515,8 +514,7 @@ s8 env_operator_precedence (const s_env *env, s_ident *op)
   s_tag tag_operator_precedence;
   s_tag tag_var;
   assert(env);
-  assert(call);
-  assert(dest);
+  assert(op);
   ident_resolve_module(op, env);
   tag_init_ident(&tag_ident, op);
   tag_init_1(    &tag_operator_precedence, ":operator_precedence");
@@ -525,13 +523,13 @@ s8 env_operator_precedence (const s_env *env, s_ident *op)
       &tag_ident, &tag_operator_precedence, &tag_var,
       NULL, NULL });
   if (! facts_with_cursor_next(&cursor))
-    errx(1, "operator %s not found in module %s",
-         op->sym->str.ptr.ps8,
-         op->module_name->str.ptr.ps8);
-  if (tag_var.type.type != TAG_U8)
-    errx(1, "%s.%s: invalid operator_precedence type",
-         op->module_name->str.ptr.ps8,
-         op->sym->str.ptr.ps8);
+    return -1;
+  if (tag_var.type.type != TAG_U8) {
+    warnx("%s.%s: invalid operator_precedence type",
+          op->module_name->str.ptr.ps8,
+          op->sym->str.ptr.ps8);
+    return -1;
+  }
   facts_with_cursor_clean(&cursor);
   return tag_var.data.u8;
 }