diff --git a/releasenotes.md b/releasenotes.md index 2cbe97a7b..48bf41e0e 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -2,7 +2,8 @@ ## 0.7.2 Change list -No changes yet +### Fixes +- Assert triggered when casting from `int[2]` to `uint[2]` #2115 ## 0.7.1 Change list diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 76136ba99..5d7b83e67 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -2199,7 +2199,7 @@ static void cast_arr_to_vec(Expr *expr, Type *to_type) static void cast_arr_to_arr(Expr *expr, Type *to_type) { ASSERT(type_size(to_type) == type_size(expr->type)); - expr->type = to_type; + expr_rewrite_recast(expr, to_type); } static void cast_anyfault_to_bool(Expr *expr, Type *to_type) diff --git a/test/test_suite/cast/cast_unsigned_signed_arr.c3t b/test/test_suite/cast/cast_unsigned_signed_arr.c3t new file mode 100644 index 000000000..a40dba66c --- /dev/null +++ b/test/test_suite/cast/cast_unsigned_signed_arr.c3t @@ -0,0 +1,29 @@ +// #target: macos-x64 +module test; +fn void main() +{ + uint[2] v; + foo(v); +} + +fn void foo(int[2] v) {} + +/* #expect: test.ll + +define void @test.main() #0 { +entry: + %v = alloca [2 x i32], align 4 + store i32 0, ptr %v, align 4 + %ptradd = getelementptr inbounds i8, ptr %v, i64 4 + store i32 0, ptr %ptradd, align 4 + %0 = load i64, ptr %v, align 4 + call void @test.foo(i64 %0) + ret void +} + +define void @test.foo(i64 %0) #0 { +entry: + %v = alloca [2 x i32], align 4 + store i64 %0, ptr %v, align 4 + ret void +}