diff options
| author | gingerBill <bill@gingerbill.org> | 2018-09-09 13:58:23 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-09-09 13:58:23 +0100 |
| commit | 76848e8807543cf1e3a6675dc404bbb0de392471 (patch) | |
| tree | b23e1fa12a98bd242b007959b6b90c710c1cecad /src/checker.cpp | |
| parent | 12902821d63973e49f34fe5826f1069ca4ea605b (diff) | |
Disallow `inline` for recursive procedures
Diffstat (limited to 'src/checker.cpp')
| -rw-r--r-- | src/checker.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index ff5375a07..6e8e9fadf 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -3344,7 +3344,7 @@ void check_parsed_files(Checker *c) { } } - TIME_SECTION("check for type cycles"); + TIME_SECTION("check for type cycles and inline cycles"); // NOTE(bill): Check for illegal cyclic type declarations for_array(i, c->info.definitions) { Entity *e = c->info.definitions[i]; @@ -3354,6 +3354,18 @@ void check_parsed_files(Checker *c) { if (align > 0 && ptr_set_exists(&c->info.minimum_dependency_set, e)) { add_type_info_type(&c->init_ctx, e->type); } + } else if (e->kind == Entity_Procedure) { + DeclInfo *decl = e->decl_info; + ast_node(pl, ProcLit, decl->proc_lit); + if (pl->inlining == ProcInlining_inline) { + for_array(j, decl->deps.entries) { + Entity *dep = decl->deps.entries[j].ptr; + if (dep == e) { + error(e->token, "Cannot inline recursive procedure '%.*s'", LIT(e->token.string)); + break; + } + } + } } } |