diff options
Diffstat (limited to 'parser.c')
| -rw-r--r-- | parser.c | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -576,14 +576,14 @@ static void parse_fn_decl(struct fn_decl_node* p_node) { expect(TK_IDENT); - if (scope_define_var(scope, (struct var_def) { - .name = tok.data.ident, - .loc = { - .type = STO_FN, - .decl = p_node, - }, - }) == NULL) - PARSER_PANIC("redefinition of '%s'", tok.data.ident) + /* redefinition is allowed */ + scope_define_var(scope, (struct var_def) { + .name = tok.data.ident, + .loc = { + .type = STO_FN, + .decl = p_node, + }, + }); p_node->name = tok.data.ident; @@ -600,7 +600,12 @@ static void parse_fn_decl(struct fn_decl_node* p_node) { expect(TK_RPAREN); - parse_group(&p_node->body); + peek_or_panic(); + if (tok.type == TK_SEMI) expect(TK_SEMI); + else { + p_node->body = ccc_alloc(sizeof(struct group_node)); + parse_group(p_node->body); + } scope_pop(&scope); } |
