From fc6c746a726b3a56f2489c3db884c8ac2cd491d7 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Wed, 30 Oct 2019 23:36:43 -0400 Subject: minor improvements to error reporting --- location.c | 1 + test.toc | 3 ++- types.c | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/location.c b/location.c index 74b032c..48fd269 100644 --- a/location.c +++ b/location.c @@ -1,3 +1,4 @@ static bool location_after(Location a, Location b) { /* a is after b? */ + assert(a.ctx == b.ctx); return a.code > b.code; } diff --git a/test.toc b/test.toc index be70155..fa54fc3 100644 --- a/test.toc +++ b/test.toc @@ -7,10 +7,11 @@ Point @= struct { x, y : int; something:fn(f32); z,asdfasdfasdf:(int,int); - safdasdjfhsj@int=3; + }; main @= fn() { p:Point; +a:p; // asasdfdsfa:(int,int); }; diff --git a/types.c b/types.c index 0932496..1f7169f 100644 --- a/types.c +++ b/types.c @@ -363,7 +363,13 @@ static bool type_resolve(Typer *tr, Type *t, Location where) { /* just check if it's actually defined */ if (!ident_typeval(t->user.name)) { char *s = ident_to_str(t->user.name); - err_print(where, "Use of undeclared type %s.", s); + IdentDecl *idecl = ident_decl(t->user.name); + if (idecl) { + err_print(where, "Use of non-type identifier %s as type.", s); + info_print(idecl->decl->where, "%s is declared here.", s); + } else { + err_print(where, "Use of undeclared type %s.", s); + } free(s); return false; } -- cgit v1.2.3