diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-04-01 17:44:43 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-04-01 17:44:43 -0400 |
commit | a251f565b97987dbd505f7f063d9a8e041036b3c (patch) | |
tree | 655cf44d9e7ba25c23d5959878195637bab13127 | |
parent | 157ffb0e7c17c61d05462e5ffdce19620485b0b1 (diff) |
fixed the fact that sometimes you didnt get redeclaration errors
-rw-r--r-- | err.c | 13 | ||||
-rw-r--r-- | parse.c | 4 | ||||
-rw-r--r-- | test.toc | 15 |
3 files changed, 7 insertions, 25 deletions
@@ -70,14 +70,11 @@ static void print_pos_highlight(FILE *out, ErrCtx *ctx, File *file, U32 start_po } static void print_location_highlight(FILE *out, Location where) { - if (where.start) { - File *f = where.file; - ErrCtx *ctx = f->ctx; - Token *first = &f->tokens[where.start]; - Token *last = &f->tokens[where.end-1]; - print_pos_highlight(out, ctx, f, first->pos.start, last->pos.end); - } - + File *f = where.file; + ErrCtx *ctx = f->ctx; + Token *first = &f->tokens[where.start]; + Token *last = &f->tokens[where.end-1]; + print_pos_highlight(out, ctx, f, first->pos.start, last->pos.end); } /* for debugging */ @@ -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."); @@ -1,19 +1,4 @@ #include "std/io.toc"; - -s ::= fn(t:: Type) Type { - struct { - c :: t = 7 as t; - m: t; - } -} -puti ::= fn() { -} - puti ::= fn() { } -main ::= fn() { - o: s(int); - x := o["m"]; - y ::= o["c"]; -} |