From 3467f27c4c0d44f5bb2a09d93a96c71a4c0eeccc Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Mon, 27 Jan 2020 13:01:36 -0500 Subject: fixed #include scoping problems --- main.c | 1 - scope.c | 2 ++ test.toc | 3 +++ types.h | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 6d0ae5c..0f12fbb 100644 --- a/main.c +++ b/main.c @@ -18,7 +18,6 @@ /* TODO: -#include nested packages constants in structs #if diff --git a/scope.c b/scope.c index 0a05bae..1b116b7 100644 --- a/scope.c +++ b/scope.c @@ -75,6 +75,8 @@ static void block_exit(Block *b, Statement *stmts) { if (stmt->kind == STMT_DECL) { Declaration *decl = &stmt->decl; remove_ident_decls(b, decl); + } else if (stmt->kind == STMT_INCLUDE) { + block_exit(b, stmt->inc.stmts); } } } diff --git a/test.toc b/test.toc index 9e82451..4274d97 100644 --- a/test.toc +++ b/test.toc @@ -2,7 +2,10 @@ arr ::= pkg "std/arr"; io ::= pkg "std/io"; main ::= fn() { #include "incstuff.toc"; + { + #include "incstuff.toc"; + } s : [1]char; s[0] = (arr.arr_len(x) as char) + '0'; io.puts(s[:]); diff --git a/types.h b/types.h index 25ddad6..17184ea 100644 --- a/types.h +++ b/types.h @@ -754,7 +754,7 @@ typedef struct Expression { } del; struct { struct Expression *name_expr; - } pkg; /* only can exist before typing */ + } pkg; /* can only exist before typing */ IfExpr if_; WhileExpr while_; ForExpr *for_; -- cgit v1.2.3