aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-09-23 20:47:02 +0100
committerGinger Bill <bill@gingerbill.org>2017-09-23 20:47:02 +0100
commit96bf6a5bcb0643408d03d4ef4a89c4b858df813e (patch)
treed6bd27d248783f18f06765740ddfbcc18f0fe458 /src
parentc43d66c286c0cf622402bd1e21f2bbc7de2a6b49 (diff)
Fix cyclic importation error printing
Diffstat (limited to 'src')
-rw-r--r--src/checker.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index dd53a7902..30bf65418 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -2838,14 +2838,18 @@ void check_import_entities(Checker *c) {
return token;
};
- Scope *s = path[0];
- Token token = mt(s);
- error(token, "Cyclic importation of `%.*s`", LIT(token.string));
- for (isize i = path.count-1; i >= 0; i--) {
- gb_printf_err("\t`%.*s` refers to", LIT(token.string));
- s = path[i];
+
+ if (path.count > 0) {
+ Scope *s = path[path.count-1];
+ Token token = mt(s);
+ error(token, "Cyclic importation of `%.*s`", LIT(token.string));
+ for (isize i = 0; i < path.count; i++) {
+ gb_printf_err("\t`%.*s` refers to\n", LIT(token.string));
+ s = path[i];
+ token = mt(s);
+ }
+ gb_printf_err("\t`%.*s`\n", LIT(token.string));
}
- gb_printf_err("\t`%.*s`", LIT(token.string));
}
}