mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Assert on defining a const fault enum with enumerator and fault of the same name. #2732
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.");
|
||||
|
||||
@@ -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;
|
||||
|
||||
10
test/test_suite/enumerations/recursive_const_enum.c3
Normal file
10
test/test_suite/enumerations/recursive_const_enum.c3
Normal file
@@ -0,0 +1,10 @@
|
||||
module main;
|
||||
|
||||
faultdef F;
|
||||
|
||||
enum Foo : const fault
|
||||
{
|
||||
F = F // #error: Recursive resolution of expression
|
||||
}
|
||||
|
||||
fn void main() {}
|
||||
Reference in New Issue
Block a user