Commit 95ba4751b791a59786b1313107ce1ed76763b6a3

Thomas de Grivel 2023-03-13T16:33:00

wip

diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index ead4457..41fe637 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -218,13 +218,16 @@ sw buf_parse_call_op_rec (s_buf *buf, s_call *dest, u8 min_precedence)
   assert(buf);
   assert(dest);
   buf_save_init(buf, &save);
-  tmp = *dest;
+  call_init_op(&tmp);
   left = &tmp.arguments->tag;
   right = &list_next(tmp.arguments)->tag;
+  *left = dest->arguments->tag;
   if ((r = buf_parse_ident_peek(buf, &next_op)) <= 0)
     goto clean;
-  if ((op_precedence = operator_precedence(&next_op)) < 0)
+  if ((op_precedence = operator_precedence(&next_op)) < 0) {
+    r = 0;
     goto restore;
+  }
   while (r && op_precedence >= min_precedence) {
     if ((r = buf_parse_ident(buf, &next_op)) <= 0)
       goto clean;
@@ -262,8 +265,11 @@ sw buf_parse_call_op_rec (s_buf *buf, s_call *dest, u8 min_precedence)
     }
     if ((op_precedence = operator_precedence(&next_op)) < 0)
       goto restore;
-    tmp.ident = op;
-    tag_init_call(left, &tmp);
+    call_init_op(&tmp2);
+    tmp2.ident = op;
+    tmp2.arguments->tag = *left;
+    list_next(tmp2.arguments)->tag = *right;
+    tag_init_call(left, &tmp2);
   }
   *dest = tmp;
   r = result;
diff --git a/libc3/env.c b/libc3/env.c
index 4d00a0a..09229b3 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -438,6 +438,7 @@ s_env * env_init (s_env *env)
     err(1, "env_init: module_path not found");
   }
   env->current_module = &env->c3_module;
+  env->c3_module.name = sym_1("C3");
   if (! module_load(&env->c3_module, sym_1("C3"), &env->facts)) {
     return NULL;
   }
diff --git a/test/buf_parse_test.c b/test/buf_parse_test.c
index 16a7077..9e00090 100644
--- a/test/buf_parse_test.c
+++ b/test/buf_parse_test.c
@@ -631,10 +631,10 @@ void buf_parse_test ()
   buf_parse_test_integer();
   buf_parse_test_str();
   buf_parse_test_sym();
-  buf_parse_test_ident();
   buf_parse_test_list();
   buf_parse_test_tag();
   buf_parse_test_tuple();
+  buf_parse_test_ident();
 }
 
 void buf_parse_test_bool ()