summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
Diffstat (limited to 'types.c')
-rw-r--r--types.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/types.c b/types.c
index 47b0145..34e7b08 100644
--- a/types.c
+++ b/types.c
@@ -323,6 +323,19 @@ static bool type_of_fn(Typer *tr, FnExpr *f, Location where, Type *t, U16 flags)
}
*ret_type = f->ret_type;
+ if (ret_type->kind == TYPE_TYPE) {
+ /*
+ a function which returns a type but has non-constant parameters is weird...
+ but might be useful, so let's warn
+ */
+ arr_foreach(f->params, Declaration, param) {
+ if (!(param->flags & DECL_IS_CONST)) {
+ warn_print(param->where, "Non-constant parameter in function which returns Type. (You can't call functions which return types at run-time, y'know)");
+ break;
+ }
+ }
+ }
+
ret:
arr_remove_last(&tr->blocks);
tr->block = prev_block;