diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-09-21 18:48:41 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-09-21 18:48:41 -0400 |
commit | 098499d4ca6cc5157f71e9d199f4eb14b91c90e1 (patch) | |
tree | 79f9201de819c458c22326ceb1456d76f4cf063e /types.c | |
parent | a1099999e02fb87e3f5f209dfbba3f93692953db (diff) |
fixed a bit of parsing
Diffstat (limited to 'types.c')
-rw-r--r-- | types.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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) { |