diff --git a/libc3/env.c b/libc3/env.c
index 2945bb7..18e86d1 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -77,32 +77,32 @@ s_tag * env_eval_call (s_env *env, const s_call *call, s_tag *dest)
s_facts_with_cursor cursor;
s_tag *result;
s_tag tag_fn;
- s_tag tag_function;
s_tag tag_ident;
s_tag tag_is_a;
s_tag tag_macro;
s_tag tag_module;
s_tag tag_module_name;
s_tag tag_sym;
+ s_tag tag_symbol;
s_tag tag_var_fn;
assert(env);
assert(call);
assert(dest);
call_copy(call, &c);
ident_resolve_module(&c.ident, env);
- tag_init_ident(&tag_ident, &c.ident);
tag_init_1( &tag_fn, ":fn");
- tag_init_1( &tag_function, ":function");
+ tag_init_ident(&tag_ident, &c.ident);
tag_init_1( &tag_is_a, ":is-a");
tag_init_1( &tag_macro, ":macro");
tag_init_1( &tag_module, ":module");
tag_init_sym( &tag_module_name, c.ident.module_name);
tag_init_sym( &tag_sym, call->ident.sym);
+ tag_init_1( &tag_symbol, ":symbol");
tag_init_var( &tag_var_fn);
facts_with(&env->facts, &cursor, (t_facts_spec) {
&tag_module_name,
&tag_is_a, &tag_module, /* module exists */
- &tag_function, &tag_ident, NULL, /* module exports symbol */
+ &tag_symbol, &tag_ident, NULL, /* module exports symbol */
&tag_ident, &tag_fn, &tag_var_fn,
NULL, NULL });
if (! facts_with_cursor_next(&cursor))
@@ -153,11 +153,21 @@ s_tag * env_eval_call_fn (s_env *env, const s_call *call, s_tag *dest)
assert(fn);
frame_init(&frame, env->frame);
env->frame = &frame;
- args = env_eval_call_arguments(env, call->arguments);
- if (env_eval_equal_list(env, fn->pattern, args, &tmp)) {
- env_eval_progn(env, fn->algo, dest);
+ if (call->arguments) {
+ if (! (args = env_eval_call_arguments(env, call->arguments)))
+ return NULL;
+ if (! env_eval_equal_list(env, fn->pattern, args, &tmp)) {
+ list_delete_all(args);
+ return NULL;
+ }
+ }
+ if (! env_eval_progn(env, fn->algo, dest)) {
+ list_delete_all(args);
list_delete_all(tmp);
+ return NULL;
}
+ list_delete_all(args);
+ list_delete_all(tmp);
env->frame = frame_clean(&frame);
return dest;
}
@@ -215,12 +225,12 @@ bool env_eval_equal_tag (s_env *env, const s_tag *a, const s_tag *b,
if (b->type.type == TAG_IDENT)
warnx("TAG_IDENT = TAG_IDENT");
tag_copy(b, dest);
- frame_binding_new(env->frame, a->data.ident.sym, dest);
+ frame_binding_new(env->frame, a->data.ident.sym, b);
return true;
}
if (b->type.type == TAG_IDENT) {
tag_copy(a, dest);
- frame_binding_new(env->frame, b->data.ident.sym, dest);
+ frame_binding_new(env->frame, b->data.ident.sym, a);
return true;
}
if (a->type.type != b->type.type) {
diff --git a/libc3/frame.c b/libc3/frame.c
index 3283e49..cccdff2 100644
--- a/libc3/frame.c
+++ b/libc3/frame.c
@@ -18,7 +18,8 @@
#include "frame.h"
#include "list.h"
-void frame_binding_new (s_frame *frame, const s_sym *name, s_tag *value)
+void frame_binding_new (s_frame *frame, const s_sym *name,
+ const s_tag *value)
{
frame->bindings = binding_new(name, value, frame->bindings);
}
diff --git a/libc3/frame.h b/libc3/frame.h
index 3ee0890..607a3fb 100644
--- a/libc3/frame.h
+++ b/libc3/frame.h
@@ -28,7 +28,8 @@ void frame_delete (s_frame *frame);
void frame_delete_all (s_frame *frame);
/* modifiers */
-void frame_binding_new(s_frame *frame, const s_sym *name, s_tag *value);
+void frame_binding_new(s_frame *frame, const s_sym *name,
+ const s_tag *value);
/* observers */
const s_tag * frame_get (s_frame *frame, const s_sym *sym);
diff --git a/test/ic3/function_call.in b/test/ic3/function_call.in
deleted file mode 100644
index a6db9d7..0000000
--- a/test/ic3/function_call.in
+++ /dev/null
@@ -1,17 +0,0 @@
-a = fn {
- (u8 x) { 8 * x }
- (s8 x) { -8 * x }
- (u16 x) { 16 * x }
- (s16 x) {
- -16 * x
- }
-}
-
-a(1)
-a(2)
-a(-1)
-a(-2)
-a(1000)
-a(2000)
-a(-1000)
-a(-2000)