Allow inference across && #2172.

This commit is contained in:
Christoffer Lerno
2025-06-05 14:20:40 +02:00
parent c9d9127da6
commit d6d0e08906
3 changed files with 11 additions and 2 deletions

View File

@@ -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.

View File

@@ -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;

View File

@@ -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()