Commit 818d68fb922531be6190becc76e889c1203b1545

Thomas de Grivel 2024-03-22T16:50:09

def

diff --git a/libc3/env.c b/libc3/env.c
index 6b8f017..f14e6f3 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -54,7 +54,7 @@ static s_env * env_init_args (s_env *env, int argc, char **argv);
 void env_clean (s_env *env)
 {
   assert(env);
-  facts_save_file(&env->facts, "debug.facts");
+  //facts_save_file(&env->facts, "debug.facts"); // debug
   frame_delete_all(env->frame);
   error_handler_delete_all(env->error_handler);
   facts_clean(&env->facts);
@@ -71,7 +71,7 @@ void env_clean (s_env *env)
 
 s_tag * env_def (s_env *env, const s_call *call, s_tag *dest)
 {
-  s_tag *tag_ident;
+  s_tag tag_ident;
   s_tag tag_module;
   s_tag tag_symbol;
   s_tag tag_symbol_value;
@@ -89,18 +89,19 @@ s_tag * env_def (s_env *env, const s_call *call, s_tag *dest)
     assert(! "env_def: invalid assignment: expected Ident = value");
     return NULL;
   }
-  tag_init_sym(&tag_module, call->arguments->tag.data.ident.module);
+  tag_init_ident(&tag_ident, &call->arguments->tag.data.ident);
+  env_ident_resolve_module(env, &tag_ident.data.ident);
+  tag_init_sym(&tag_module, tag_ident.data.ident.module);
   tag_init_sym(&tag_symbol, &g_sym_symbol);
-  tag_ident = &call->arguments->tag;
   tag_init_sym(&tag_symbol_value, &g_sym_symbol_value);
   tag_value = &list_next(call->arguments)->tag;
   if (! facts_add_tags(&env->facts, &tag_module, &tag_symbol,
-                       tag_ident))
+                       &tag_ident))
     return NULL;
-  if (! facts_add_tags(&env->facts, tag_ident, &tag_symbol_value,
+  if (! facts_add_tags(&env->facts, &tag_ident, &tag_symbol_value,
                        tag_value))
     return NULL;
-  tag_init_ident(dest, &call->arguments->tag.data.ident);
+  tag_init_ident(dest, &tag_ident.data.ident);
   return dest;
 }