summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-07-12 14:45:29 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-07-12 14:45:29 -0400
commita7d209081a9f59f9d347ab87f76d0b58dc7cc106 (patch)
tree165238bf6f7431a6136ecbb7660bdf9a5aa28dc2
parentad700fb033e47377f7945e10facc3475da0b747c (diff)
reduce number of errors if an include failed
-rw-r--r--main.c1
-rw-r--r--test.toc5
-rw-r--r--types.c7
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;