summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/parse.c b/parse.c
index f269ea9..1cf18bf 100644
--- a/parse.c
+++ b/parse.c
@@ -1002,8 +1002,8 @@ static Identifier parser_ident_insert(Parser *p, char *str) {
static Status check_ident_redecl(Parser *p, Identifier i) {
Tokenizer *t = p->tokr;
- if (i->idents == &p->block->idents) {
- if (i->decl_kind != IDECL_NONE) {
+ if (i->idents == (p->block ? &p->block->idents : p->globals)) { /* in the same scope */
+ if (i->decl_kind != IDECL_NONE) { /* declared */
char *s = ident_to_str(i);
tokr_err(t, "Redeclaration of identifier %s.", s);
info_print(ident_decl_location(p->file, i), "Previous declaration was here.");