From a7d209081a9f59f9d347ab87f76d0b58dc7cc106 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 12 Jul 2020 14:45:29 -0400 Subject: reduce number of errors if an include failed --- main.c | 1 - test.toc | 5 +++-- types.c | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 2aac34f..d63a6fb 100644 --- a/main.c +++ b/main.c @@ -8,7 +8,6 @@ see development.md for development information @TODO: -if we do #include "foo.toc", bar; and foo.toc fails, bar should be declared as TYPE_UNKNOWN (right now it's undeclared) fix #foreign not at global scope - right now the cgen'd definition doesn't use the proper type figure out how printf is gonna work improve type_to_str: diff --git a/test.toc b/test.toc index 7a8105f..88e007c 100644 --- a/test.toc +++ b/test.toc @@ -1,6 +1,7 @@ -#include "std/io.toc", io; +#include "main.c", t; + main ::= fn() { - io.puts("Hello, world!"); + t.puts("hi"); } main(); diff --git a/types.c b/types.c index 480d146..3d657ed 100644 --- a/types.c +++ b/types.c @@ -3878,7 +3878,6 @@ top: { char *contents = read_file_contents(tr->allocr, filename, s->where); if (!contents) { - tr->had_include_err = true; success = false; goto nms_done; } @@ -3919,7 +3918,11 @@ top: tr->block = prev_block; } if (inc_f) inc_f->flags &= (IncFileFlags)~(IncFileFlags)INC_FILE_INCLUDING; - if (!success) return false; + if (!success) { + // give up on typing if #include failed + tr->had_include_err = true; + return false; + } } break; case STMT_MESSAGE: { Message *m = s->message; -- cgit v1.2.3