summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/main.c b/main.c
index ae19e7a..fa00bad 100644
--- a/main.c
+++ b/main.c
@@ -161,9 +161,13 @@ void parse_assign(Lexer *l, Proc *p) {
type_desc(&e->type, &p->arena),
type_desc(&b->node->type, &p->arena)));
}
- if (e->op == N_UNINIT) {
+ if (node_uninit(e)) {
lex_error_at(l, e->src_pos, LE_ERROR,
- str_fmt(&p->arena, "assigning from uninitialized %S value",
+ str_fmt(&p->arena, "uninitialized %S",
+ type_desc(&e->type, &p->arena)));
+ } else if (node_maybe_uninit(e)) {
+ lex_error_at(l, e->src_pos, LE_WARN,
+ str_fmt(&p->arena, "possibly uninitialized %S",
type_desc(&e->type, &p->arena)));
}
scope_update(b, e, p);
@@ -659,6 +663,9 @@ void node_print(Node *n, Proc *p) {
} else if (n->op == N_PROJ) {
Str d = type_desc(&n->in.data[0]->val.tuple.data[n->val.i].type, &p->arena);
printf("\t%d [label=\"%.*s(%ld)\", shape=record]", n->id, (int)d.n, d.s, n->val.i);
+ } else if (n->op == N_UNINIT) {
+ Str s = type_desc(&n->type, &p->arena);
+ printf("\t%d [label=\"uninitialized %.*s\", shape=record]", n->id, (int)s.n, s.s);
} else {
printf("\t%d [label=\"%s\", shape=record]", n->id, node_type_name(n->op));
}