diff --git a/releasenotes.md b/releasenotes.md index af2f0826e..d5007eca5 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -9,6 +9,7 @@ - Implicitly convert from constant typeid to Type in `$Type` assignment, and `$assignable`. - Make $Type parameters accept constant typeid values. - Deprecate `foo.#bar`. +- Allow inference across `&&` #2172. ### Fixes - `-2147483648`, MIN literals work correctly. diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index abcd6d8e7..b6246c66f 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -10965,6 +10965,12 @@ RETRY: case EXPR_CT_ARG: if (!sema_expr_analyse_ct_arg(context, to, expr)) return expr_poison(expr); break; + case EXPR_UNARY: + if (expr->unary_expr.operator == UNARYOP_TADDR && to->canonical->type_kind == TYPE_POINTER && to->canonical != type_voidptr) + { + if (!sema_analyse_inferred_expr(context, type_get_indexed_type(to), expr->unary_expr.expr)) return expr_poison(expr); + } + FALLTHROUGH; default: if (!sema_analyse_expr_dispatch(context, expr, CHECK_VALUE)) return expr_poison(expr); break; diff --git a/test/test_suite/errors/optional_untyped_list.c3 b/test/test_suite/errors/optional_untyped_list.c3 index dc4bee854..25abb62c4 100644 --- a/test/test_suite/errors/optional_untyped_list.c3 +++ b/test/test_suite/errors/optional_untyped_list.c3 @@ -11,13 +11,15 @@ extern fn int printf(char *c, ...); fn void foo() { int z = 2; - Foo*? w = &&{ z, 0 }; // #error: An untyped list can only have constant elements + ushort* y = &&4; + Foo*? w2 = &&{ z, 0 }; + void*? w = &&{ z, 0 }; // #error: An untyped list can only have constant elements } fn void foo2() { int? z = 2; - Foo*? w = &&{ z, 0 }; // #error: An untyped list can only have constant elements + void*? w = &&{ z, 0 }; // #error: An untyped list can only have constant elements } fn void test()