summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test.toc12
-rw-r--r--tests/control_flow.toc2
-rw-r--r--tests/defer.toc2
-rw-r--r--types.c7
4 files changed, 9 insertions, 14 deletions
diff --git a/test.toc b/test.toc
index 24b13b7..ec5fe91 100644
--- a/test.toc
+++ b/test.toc
@@ -1,4 +1,3 @@
-/*
#include "std/io.toc", io;
#include "std/base.toc", base;
@@ -14,14 +13,3 @@ main ::= fn() {
io.file_writes(&io.std_err, "something went wrong!\n");
}
main();
-*/
-
-a ::= nms {
- #if 1 {
- test ::= 0x501;
- foo ::= fn() {
- test;
- }
- }
-}
-
diff --git a/tests/control_flow.toc b/tests/control_flow.toc
index 043d4b7..f54a8bc 100644
--- a/tests/control_flow.toc
+++ b/tests/control_flow.toc
@@ -8,7 +8,7 @@ f ::= fn() int {
if i == 7 { break; }
}
i := 0;
- while {
+ while true {
i += 1;
total += i;
if i == 10 {
diff --git a/tests/defer.toc b/tests/defer.toc
index ec06a19..07ef9f7 100644
--- a/tests/defer.toc
+++ b/tests/defer.toc
@@ -50,7 +50,7 @@ main ::= fn() {
}
}
i := 0;
- while {
+ while true {
defer io.puts("deferred from while");
i += 1;
io.puti(i);
diff --git a/types.c b/types.c
index d04279b..42267bd 100644
--- a/types.c
+++ b/types.c
@@ -3601,6 +3601,7 @@ static Status types_decl(Typer *tr, Declaration *d) {
static Status fix_ident_decls_inline_block(Typer *tr, Statement *stmts) {
Identifiers *idents = typer_get_idents(tr);
arr_foreach(stmts, Statement, s) {
+ assert(!(s->flags & STMT_TYPED));
if (s->kind == STMT_DECL) {
Declaration *d = s->decl;
arr_foreach(d->idents, Identifier, ident) {
@@ -3675,6 +3676,12 @@ static Status types_stmt(Typer *tr, Statement *s) {
s->inline_block = true_block->stmts;
if (!fix_ident_decls_inline_block(tr, s->inline_block))
return false;
+ /*
+ erase identifiers in old block - we don't want anyone to think that
+ stuff is actually declared in the old block.
+ this isn't ideal, but oh well
+ */
+ idents_create(&true_block->idents, tr->allocr, true_block);
bool success = true;
arr_foreach(s->inline_block, Statement, sub) {
if (!types_stmt(tr, sub)) {