diff --git a/libc3/env.c b/libc3/env.c
index 92e5255..8ec093d 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -2087,6 +2087,8 @@ bool env_module_maybe_reload (s_env *env, const s_sym *module,
bool r = true;
s_tag tag_load_time = {0};
s_tag tag_mtime;
+ if (env_module_is_loading(env, module))
+ return true;
module_load_time(module, facts, &tag_load_time);
if ((! module_path(module, &env->module_path, C3_EXT, &path) ||
! file_access(&path, &g_sym_r)) &&
diff --git a/libc3/module.c b/libc3/module.c
index 98de5b5..3eddc90 100644
--- a/libc3/module.c
+++ b/libc3/module.c
@@ -146,10 +146,12 @@ s_str * module_path (const s_sym *module, const s_str *prefix,
if ((r = buf_write_1(&out, ext)) < 0)
goto error;
result = buf_to_str(&out, dest);
+ /*
if (result) {
err_inspect_str(dest);
err_write_1("\n");
}
+ */
return result;
error:
buf_clean(&out);
diff --git a/test/ic3/def.in b/test/ic3/def.in
index 6305fca..39e95b5 100644
--- a/test/ic3/def.in
+++ b/test/ic3/def.in
@@ -34,20 +34,44 @@ quote double_tuple(zero)
double_tuple(zero)
quote double_tuple(one_two_three)
double_tuple(one_two_three)
-quote def reverse = fn (x) { List.reverse(x) }
-def reverse = fn (x) { List.reverse(x) }
+quote def reverse = fn {
+ (x) { reverse(x, []) }
+ ([], acc) { acc }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
+def reverse = fn {
+ (x) { reverse(x, []) }
+ ([], acc) { acc }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
quote C3.reverse
C3.reverse
quote reverse([1, 2, 3])
reverse([1, 2, 3])
-quote def reverse = fn (x) { [:reversed | List.reverse(x)] }
-def reverse = fn (x) { [:reversed | List.reverse(x)] }
+quote def reverse = fn {
+ (x) { reverse(x, []) }
+ ([], acc) { [:reversed | acc] }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
+def reverse = fn {
+ (x) { reverse(x, []) }
+ ([], acc) { [:reversed | acc] }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
quote C3.reverse
C3.reverse
quote reverse([1, 2, 3])
reverse([1, 2, 3])
-quote def reverse = fn (x) { List.reverse(x) }
-def reverse = fn (x) { List.reverse(x) }
+quote def reverse = fn {
+ (x) { reverse(x, []) }
+ ([], acc) { acc }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
+def reverse = fn {
+ (x) { reverse(x, []) }
+ ([], acc) { acc }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
quote C3.reverse
C3.reverse
quote reverse([1, 2, 3])
diff --git a/test/ic3/def.out.expected b/test/ic3/def.out.expected
index 494bdec..6997c75 100644
--- a/test/ic3/def.out.expected
+++ b/test/ic3/def.out.expected
@@ -34,21 +34,45 @@ double_tuple(zero)
{0, 0}
double_tuple(one_two_three)
{[1, 2, 3], [1, 2, 3]}
-def reverse = fn (x) { List.reverse(x) }
+def reverse = fn {
+ (x) { reverse(x, []) }
+ ([], acc) { acc }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
reverse
reverse
-fn (x) { List.reverse(x) }
+fn {
+ (x) { reverse(x, []) }
+ ([], acc) { acc }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
reverse([1, 2, 3])
[3, 2, 1]
-def reverse = fn (x) { [:reversed | List.reverse(x)] }
+def reverse = fn {
+ (x) { reverse(x, []) }
+ ([], acc) { [:reversed | acc] }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
reverse
reverse
-fn (x) { [:reversed | List.reverse(x)] }
+fn {
+ (x) { reverse(x, []) }
+ ([], acc) { [:reversed | acc] }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
reverse([1, 2, 3])
[:reversed, 3, 2, 1]
-def reverse = fn (x) { List.reverse(x) }
+def reverse = fn {
+ (x) { reverse(x, []) }
+ ([], acc) { acc }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
reverse
reverse
-fn (x) { List.reverse(x) }
+fn {
+ (x) { reverse(x, []) }
+ ([], acc) { acc }
+ ([a | b], acc) { reverse(b, [a | acc]) }
+}
reverse([1, 2, 3])
[3, 2, 1]