Skip to content

Commit

Permalink
Fix issue with compiler errors thrown by AST nodes with no annotated …
Browse files Browse the repository at this point in the history
…position
  • Loading branch information
StavromulaBeta committed Aug 30, 2024
1 parent 656d869 commit c433a2b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/cognac.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ _Noreturn void throw_error(char* message, where_t* where)
exit(-1);
*/

if (!where)
{
fputs(message, stderr);
exit(EXIT_FAILURE);
}

// Calculate width of the "[LINE_NUMBER]" bit
message = strdup(message);
char number_box[64];
Expand Down Expand Up @@ -1340,7 +1346,7 @@ void add_generics(module_t* mod)
tree->next->prev = tree;
tree->next->next = NULL;
insert_op_after(
make_op(static_call, f->func, NULL), tree);
make_op(static_call, f->func, f->func->ops->op->where), tree);
char* name = make_func_name();
func_t* f_ = make_func(tree, name);
f_->generic = true;
Expand Down Expand Up @@ -1456,15 +1462,15 @@ void _add_arguments(func_t* f)
{
for (size_t i = 0 ; i < f->argc ; ++i)
{
insert_op_after(make_op(unpick, NULL, NULL), f->ops);
insert_op_after(make_op(load, NULL, NULL), f->ops);
insert_op_after(make_op(unpick, NULL, f->ops->op->where), f->ops);
insert_op_after(make_op(load, NULL, f->ops->op->where), f->ops);
f->args = push_val(make_value(any, f->ops), f->args);
}
if (f->returns)
{
ast_list_t* end = f->ops;
while (end->next) end = end->next;
insert_op_before(make_op(ret, NULL, NULL), end);
insert_op_before(make_op(ret, NULL, end->prev->op->where), end);
f->rettype = any;
}
f->args = reverse(f->args);
Expand Down

0 comments on commit c433a2b

Please sign in to comment.