diff --git a/releasenotes.md b/releasenotes.md index 534aaea24..c0f560a2e 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -86,6 +86,7 @@ - Make `log` and `exp` no-strip. - `@test`/`@benchmark` on module would attach to interface and regular methods. - Deprecated `@select` in favor of `???`. +- Enum inference, like `Foo x = $eval("A")`, now works correctly for `$eval`. ### Stdlib changes - Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`. diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index fbcf33643..88d6de851 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -11821,6 +11821,9 @@ RETRY: case EXPR_RETHROW: if (!sema_expr_analyse_rethrow(context, expr, original_type)) return expr_poison(expr); break; + case EXPR_CT_EVAL: + if (!sema_expr_resolve_ct_eval(context, expr)) return expr_poison(expr); + goto RETRY; case EXPR_UNARY: if (to && expr->unary_expr.operator == UNARYOP_TADDR && to->canonical->type_kind == TYPE_POINTER && to->canonical != type_voidptr) { diff --git a/test/test_suite/compile_time/ct_eval_infer.c3t b/test/test_suite/compile_time/ct_eval_infer.c3t new file mode 100644 index 000000000..d79ef7e68 --- /dev/null +++ b/test/test_suite/compile_time/ct_eval_infer.c3t @@ -0,0 +1,20 @@ +module test; +import std; + +enum Foo +{ + A, B +} + +struct Test +{ + Foo a; +} +fn void main() +{ + + var $member = Test.membersof[0]; + Test x; + x.a = $eval("A"); + io::printn(x); +} \ No newline at end of file