- Assert on defining a const fault enum with enumerator and fault of the same name. #2732

This commit is contained in:
Christoffer Lerno
2026-01-17 15:01:40 +01:00
parent c2e603ddd8
commit 6dcd91c5ef
4 changed files with 14 additions and 3 deletions

View File

@@ -63,6 +63,7 @@
- Fix to `temp_directory` on Windows #2762.
- Too little memory reserved when printing backtrace on Darwin #2698.
- In some cases, a type would not get implicitly converted to a typeid #2764.
- Assert on defining a const fault enum with enumerator and fault of the same name. #2732
### Stdlib changes
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.

View File

@@ -1777,7 +1777,7 @@ ERR:
bool sema_analyse_const_enum_constant_val(SemaContext *context, Decl *decl)
{
Expr *value = decl->enum_constant.value;
if (!sema_analyse_inferred_expr(context, decl->type, value,NULL)) return decl_poison(decl);
if (!sema_analyse_inferred_expr(context, decl->type, value, NULL)) return decl_poison(decl);
if (!expr_is_runtime_const(value))
{
SEMA_ERROR(value, "Expected an constant enum value.");

View File

@@ -19,7 +19,7 @@
expr_temp__->resolve_status = RESOLVE_DONE; \
return true; \
case RESOLVE_RUNNING: \
SEMA_ERROR(expr, "Recursive resolution of expression"); \
SEMA_ERROR(expr, "Recursive resolution of expression."); \
return expr_poison(expr_temp__); \
case RESOLVE_DONE: \
return expr_ok(expr_temp__); \
@@ -1177,7 +1177,7 @@ static inline bool sema_expr_analyse_enum_constant(SemaContext *context, Expr *e
if (enum_constant->enum_constant.is_raw)
{
expr_replace(expr, copy_expr_single(enum_constant->enum_constant.value));
return true;
return sema_analyse_expr_rvalue(context, expr);
}
expr->expr_kind = EXPR_CONST;
expr->const_expr.const_kind = CONST_ENUM;

View File

@@ -0,0 +1,10 @@
module main;
faultdef F;
enum Foo : const fault
{
F = F // #error: Recursive resolution of expression
}
fn void main() {}