From ef29776bb66629a28a3f4dfeac2d450c83a22b7b Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Wed, 12 Feb 2020 21:26:23 -0500 Subject: got rid of #cache; decided it wasnt the way to go --- types.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'types.c') 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; } -- cgit v1.2.3