summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-09-21 18:48:41 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-09-21 18:48:41 -0400
commit098499d4ca6cc5157f71e9d199f4eb14b91c90e1 (patch)
tree79f9201de819c458c22326ceb1456d76f4cf063e /types.c
parenta1099999e02fb87e3f5f209dfbba3f93692953db (diff)
fixed a bit of parsing
Diffstat (limited to 'types.c')
-rw-r--r--types.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/types.c b/types.c
index fb570b0..511614c 100644
--- a/types.c
+++ b/types.c
@@ -167,15 +167,18 @@ static bool type_of_ident(Typer *tr, Location where, Identifier i, Type *t, bool
typedef Declaration *DeclarationPtr;
arr_foreach(&tr->in_decls, DeclarationPtr, in_decl) {
if (d == *in_decl) {
- /* if we've complained about it before when we were figuring out the type, don't complain again */
- if (!(d->flags & DECL_FLAG_ERRORED_ABOUT_SELF_REFERENCE)) {
- char *s = ident_to_str(i);
- err_print(where, "Use of identifier %s within its own declaration.", s);
- free(s);
- info_print(d->where, "Declaration was here.");
- d->flags |= DECL_FLAG_ERRORED_ABOUT_SELF_REFERENCE;
+ assert(d->flags & DECL_FLAG_HAS_EXPR); /* we can only be in decls with an expr */
+ if (d->expr.kind != EXPR_FN) { /* it's okay if a function references itself */
+ /* if we've complained about it before when we were figuring out the type, don't complain again */
+ if (!(d->flags & DECL_FLAG_ERRORED_ABOUT_SELF_REFERENCE)) {
+ char *s = ident_to_str(i);
+ err_print(where, "Use of identifier %s within its own declaration.", s);
+ free(s);
+ info_print(d->where, "Declaration was here.");
+ d->flags |= DECL_FLAG_ERRORED_ABOUT_SELF_REFERENCE;
+ }
+ return false;
}
- return false;
}
}
if (!allow_use_before_decl) {