From 052ff9cc03544f29e1c3c79f09b6b0f3fb989532 Mon Sep 17 00:00:00 2001 From: A404M Date: Tue, 1 Apr 2025 12:54:56 +0330 Subject: trying to fix functions as argument and more dynamically calling functions --- src/compiler/ast-tree.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/compiler/ast-tree.c') diff --git a/src/compiler/ast-tree.c b/src/compiler/ast-tree.c index 2f9c27c..a0bc974 100644 --- a/src/compiler/ast-tree.c +++ b/src/compiler/ast-tree.c @@ -2103,6 +2103,10 @@ AstTreeFunction *getFunction(AstTree *value) { UNREACHABLE; } +bool isFunction(AstTree *value) { + return value->type->token == AST_TREE_TOKEN_TYPE_FUNCTION; +} + bool isConst(AstTree *tree, AstTreeHelper *helper) { switch (tree->token) { case AST_TREE_TOKEN_TYPE_TYPE: @@ -2954,6 +2958,10 @@ bool setTypesFunctionCall(AstTree *tree, AstTreeSetTypesHelper helper) { if (!setAllTypes(metadata->function, helper, NULL)) { return false; + } else if (!isFunction(metadata->function)) { + printError(metadata->function->str_begin, metadata->function->str_end, + "Object is not a function"); + return false; } AstTreeFunction *function = getFunction(metadata->function); -- cgit v1.2.3