summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-02-12 21:26:23 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-02-12 21:26:23 -0500
commitef29776bb66629a28a3f4dfeac2d450c83a22b7b (patch)
tree45befe36398e6f346f17fb44aba8fd0e8af1a958 /types.c
parent8d94800921520a45284164e09e5dd21da6115973 (diff)
got rid of #cache; decided it wasnt the way to go
Diffstat (limited to 'types.c')
-rw-r--r--types.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/types.c b/types.c
index 6765314..abe6795 100644
--- a/types.c
+++ b/types.c
@@ -2213,6 +2213,14 @@ static bool types_expr(Typer *tr, Expression *e) {
static bool types_block(Typer *tr, Block *b) {
if (b->flags & BLOCK_FOUND_TYPES)
return true;
+
+ if (b->flags & BLOCK_FINDING_TYPES) {
+ err_print(b->where, "A circular dependency was found when finding types in this block.\n"
+ "You are using recursion in a way that is not allowed by this language. Sorry!");
+ return false;
+ }
+ b->flags |= BLOCK_FINDING_TYPES;
+
typer_block_enter(tr, b);
bool success = true;
arr_foreach(b->stmts, Statement, s) {
@@ -2248,6 +2256,8 @@ static bool types_block(Typer *tr, Block *b) {
ret:
typer_block_exit(tr);
b->flags |= BLOCK_FOUND_TYPES;
+ b->flags &= (BlockFlags)~(BlockFlags)BLOCK_FINDING_TYPES;
+
return success;
}