From 420e44295675a7f0e935853179d856dcc0c83ad5 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Wed, 2 Oct 2024 17:24:58 +0200 Subject: [PATCH] fix swizzle in for in statement Fixes #1730 --- src/llvm_backend_general.cpp | 3 +-- tests/issues/run.bat | 1 + tests/issues/run.sh | 1 + tests/issues/test_various_issues.odin | 17 +++++++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/issues/test_various_issues.odin diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 842a1cbc80b..efa3a0ab474 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -574,8 +574,7 @@ gb_internal lbValue lb_addr_get_ptr(lbProcedure *p, lbAddr const &addr) { case lbAddr_Swizzle: case lbAddr_SwizzleLarge: - // TOOD(bill): is this good enough logic? - break; + return lb_address_from_load(p, lb_addr_load(p, addr)); } return addr.addr; diff --git a/tests/issues/run.bat b/tests/issues/run.bat index dcea3d483f4..59c4d78ae64 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -16,6 +16,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style ..\..\..\odin test ..\test_issue_2637.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_2666.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_4210.odin %COMMON% || exit /b +..\..\..\odin test ..\test_various_issues.odin %COMMON% || exit /b @echo off diff --git a/tests/issues/run.sh b/tests/issues/run.sh index c3bc00e24c2..3cb639bc597 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -17,6 +17,7 @@ $ODIN test ../test_issue_2615.odin $COMMON $ODIN test ../test_issue_2637.odin $COMMON $ODIN test ../test_issue_2666.odin $COMMON $ODIN test ../test_issue_4210.odin $COMMON +$ODIN test ../test_various_issues.odin $COMMON if [[ $($ODIN build ../test_issue_2395.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]] ; then echo "SUCCESSFUL 1/1" else diff --git a/tests/issues/test_various_issues.odin b/tests/issues/test_various_issues.odin new file mode 100644 index 00000000000..7d30a5e7f5c --- /dev/null +++ b/tests/issues/test_various_issues.odin @@ -0,0 +1,17 @@ +package test_issues + +import "core:testing" + +// Tests issue #1730 https://github.com/odin-lang/Odin/issues/1730 +@(test) +test_issue_1730 :: proc(t: ^testing.T) { + ll := [4]int{1, 2, 3, 4} + for l, i in ll.yz { + testing.expect(t, i <= 1) + if i == 0 { + testing.expect_value(t, l, 2) + } else if i == 1 { + testing.expect_value(t, l, 3) + } + } +}