diff --git a/releasenotes.md b/releasenotes.md index 6862e0acc..043210ad2 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -62,6 +62,7 @@ - Hashing a vector would not use the entire vector in some cases. - 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. ### Stdlib changes - Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads. diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index ad03fe6a8..02b62eece 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -12431,6 +12431,7 @@ RETRY: SEMA_ERROR(expr, "Recursive resolution of list."); return expr_poison(expr); case RESOLVE_DONE: + if (!sema_cast_rvalue(context, expr, true)) return false; if (to && expr->type != to) { cast_implicit_silent(context, expr, to, false); diff --git a/test/test_suite/expressions/ternary_with_implicit_type_typeid.c3 b/test/test_suite/expressions/ternary_with_implicit_type_typeid.c3 new file mode 100644 index 000000000..27845b659 --- /dev/null +++ b/test/test_suite/expressions/ternary_with_implicit_type_typeid.c3 @@ -0,0 +1,15 @@ +module testing_branch; +faultdef FOO; + +macro usz? problemz(val) => val >= 5 ? usz : FOO~; // #error: Implicitly casting 'typeid' to 'usz' +macro usz? problemz2(val) => val >= 5 ? $typefrom("usz") : FOO~; // #error: Implicitly casting 'typeid' to 'usz' + +fn int main() +{ + for (usz i = 0; i < 10; i++) + { + problemz(i)!!; + problemz2(i)!!; + } + return 0; +} \ No newline at end of file