Commit 0131304b856840b4ec534bc13a8f762f2fc66db6

Thomas de Grivel 2024-03-28T09:07:09

wip defmodule

diff --git a/ic3/.ic3_history b/ic3/.ic3_history
index 003515e..d046941 100644
--- a/ic3/.ic3_history
+++ b/ic3/.ic3_history
@@ -1,4 +1,3 @@
-  quote do
     x = unquote x
 def dt = macro (x) do
   quote do
@@ -97,3 +96,4 @@ quote Plop
 quote_cfn Plop
 (Sym) "Abc"
 defmodule Plop do end
+defmodule Plop do def a = 1 end
diff --git a/libc3/env.c b/libc3/env.c
index a9fb724..c8e92e0 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -111,7 +111,7 @@ const s_sym ** env_defmodule (s_env *env, const s_sym **name,
 {
   const s_sym *module;
   const s_sym **result = NULL;
-  s_tag tmp;
+  s_tag tmp = {0};
   assert(env);
   assert(name);
   assert(*name);
@@ -343,7 +343,8 @@ bool env_eval_call_resolve (s_env *env, s_call *call)
       return true;
     }
   }
-  ident_resolve_module(&call->ident, env);
+  if (! ident_resolve_module(&call->ident, env))
+    return false;
   if (! module_ensure_loaded(call->ident.module, &env->facts))
     return false;
   return call_get(call, &env->facts);
@@ -1333,12 +1334,17 @@ bool env_ident_is_special_operator (s_env *env,
   return false;
 }
 
-void env_ident_resolve_module (const s_env *env, s_ident *ident)
+bool env_ident_resolve_module (const s_env *env, const s_ident *ident,
+                               s_ident *dest)
 {
   assert(env);
   assert(ident);
   if (! ident->module) {
-    assert(env->current_module);
+    if (! env->current_module) {
+      err_puts("env_ident_resolve_module: env current module is NULL");
+      assert(! "env_ident_resolve_module: env current module is NULL");
+      return false;
+    }
     ident->module = env->current_module;
   }
 }