mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix error using compile time var before assignment.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define COMPILER_VERSION "0.3.76"
|
||||
#define COMPILER_VERSION "0.3.77"
|
||||
Reference in New Issue
Block a user