Fix error using compile time var before assignment.

This commit is contained in:
Christoffer Lerno
2022-10-08 21:46:56 +02:00
parent 7fa129932d
commit 70a429f832
3 changed files with 7 additions and 2 deletions

View File

@@ -6820,6 +6820,11 @@ static inline bool sema_cast_ct_ident_rvalue(SemaContext *context, Expr *expr)
{
Decl *decl = expr->ct_ident_expr.decl;
Expr *copy = copy_expr_single(decl->var.init_expr);
if (!copy)
{
SEMA_ERROR(expr, "'%s' was not yet initialized to any value, assign a value to it before use.", decl->name);
return false;
}
if (!sema_analyse_expr(context, copy)) return false;
expr_replace(expr, copy);
return true;

View File

@@ -175,7 +175,7 @@ static bool sema_resolve_type_identifier(SemaContext *context, TypeInfo *type_in
{
if (!decl->var.init_expr)
{
SEMA_ERROR(type_info, "The variable '%s' is not defined yet.", decl->name);
SEMA_ERROR(type_info, "You need to assign a type to '%s' before using it.", decl->name);
return false;
}
assert(decl->var.init_expr->expr_kind == EXPR_TYPEINFO);

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.3.76"
#define COMPILER_VERSION "0.3.77"