diff options
-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"]; -} |