summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index 085e3f8..07607f2 100644
--- a/eval.c
+++ b/eval.c
@@ -1031,7 +1031,14 @@ static bool eval_ident(Evaluator *ev, Identifier ident, Value *v, Location where
Declaration *d = NULL;
if (is_decl) {
d = idecl->decl;
-
+ if (d->flags & DECL_FOREIGN) {
+ if (!(d->flags & DECL_FOUND_VAL)) {
+ err_print(where, "Cannot access foreign declaration at compile time (you can only call foreign functions)");
+ return false;
+ }
+ v->fn = d->val.fn;
+ return true;
+ }
if ((d->flags & DECL_FOUND_VAL) && type_is_builtin(&d->type, BUILTIN_TYPE) && d->val.type->kind == TYPE_STRUCT) {
v->type = allocr_malloc(ev->allocr, sizeof *v->type);
v->type->flags = TYPE_IS_RESOLVED;