diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 9b19ac9e1..1f0c28b36 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5852,7 +5852,7 @@ gb_internal Type *determine_swizzle_array_type(Type *original_type, Type *type_h Type *elem_type = array_type->Array.elem; Type *swizzle_array_type = nullptr; - Type *bth = base_type(type_deref(type_hint)); + Type *bth = base_type(type_hint); if (bth != nullptr && bth->kind == Type_Array && bth->Array.count == new_count && are_types_identical(bth->Array.elem, elem_type)) { @@ -5860,7 +5860,7 @@ gb_internal Type *determine_swizzle_array_type(Type *original_type, Type *type_h } else { i64 max_count = array_type->Array.count; if (new_count == max_count) { - swizzle_array_type = original_type; + swizzle_array_type = type_deref(original_type); } else { swizzle_array_type = alloc_type_array(elem_type, new_count); } diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 223c80840..7bf2ea8e3 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -64,6 +64,7 @@ clang -c ..\test_issue_sysv_abi.c -o test_issue_sysv_abi_c.o || exit /b ..\..\..\odin run ..\test_issue_7482.odin %COMMON% || exit /b ..\..\..\odin run ..\test_issue_7562.odin %COMMON% -no-crt -no-thread-local || exit /b ..\..\..\odin run ..\test_issue_7562.odin %COMMON% -no-crt -no-thread-local -o:speed || exit /b +..\..\..\odin test ..\test_issue_7587.odin %COMMON% || exit /b ..\..\..\odin run ..\test_issue_7596.odin %COMMON% || exit /b @echo off diff --git a/tests/issues/run.sh b/tests/issues/run.sh index fdff52e02..775640cf6 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -94,6 +94,7 @@ $ODIN check ../test_issue_7012.odin -no-entry-point $COMMON_CHECK $ODIN build ../test_issue_7037.odin $COMMON -o:none $ODIN run ../test_issue_7482.odin $COMMON $ODIN run ../test_issue_7564.odin $COMMON +$ODIN test ../test_issue_7587.odin $COMMON $ODIN run ../test_issue_7596.odin $COMMON $ODIN test ../test_issue_7421.odin $COMMON if [[ $($ODIN check ../test_issue_7421_tagged_duplicate.odin $COMMON_CHECK 2>&1 >/dev/null | grep -c "Error: Duplicate case") -eq 1 ]]; then diff --git a/tests/issues/test_issue_7587.odin b/tests/issues/test_issue_7587.odin new file mode 100644 index 000000000..c6458a9a7 --- /dev/null +++ b/tests/issues/test_issue_7587.odin @@ -0,0 +1,16 @@ +// Tests issue #7587 https://github.com/odin-lang/Odin/issues/7587 +package test_issues + +import "core:testing" + +@(test) +test_issue_7587 :: proc(t: ^testing.T) { + v := [4]f32{1, 2, 3, 4} + p := &v + + w := p.wzyx + testing.expect_value(t, w, [4]f32{4, 3, 2, 1}) + + p.wzyx = {1, 2, 3, 4} + testing.expect_value(t, v, [4]f32{4, 3, 2, 1}) +}