diff options
| author | miere43 <x.miere@gmail.com> | 2025-12-03 21:16:18 +0300 |
|---|---|---|
| committer | miere43 <x.miere@gmail.com> | 2025-12-03 21:27:38 +0300 |
| commit | 29019d7138629af4a66c3e8faf064d9d29b5ee62 (patch) | |
| tree | 90e72f35319eea67f69e1c4a6293ad38899617c2 /tests | |
| parent | 09e516ef68ef3f120ca55a021fc2d05787d42455 (diff) | |
Fix duplicate code emission in type assertions.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/issues/run.bat | 1 | ||||
| -rwxr-xr-x | tests/issues/run.sh | 1 | ||||
| -rw-r--r-- | tests/issues/test_issue_5699.odin | 36 |
3 files changed, 38 insertions, 0 deletions
diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 4a1072e12..eeaf8e002 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -25,6 +25,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style ..\..\..\odin build ..\test_issue_5097.odin %COMMON% || exit /b ..\..\..\odin build ..\test_issue_5097-2.odin %COMMON% || exit /b ..\..\..\odin build ..\test_issue_5265.odin %COMMON% || exit /b +..\..\..\odin test ..\test_issue_5699.odin %COMMON% || exit /b @echo off diff --git a/tests/issues/run.sh b/tests/issues/run.sh index 03d84425a..86e6ce17f 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -32,6 +32,7 @@ $ODIN build ../test_issue_5043.odin $COMMON $ODIN build ../test_issue_5097.odin $COMMON $ODIN build ../test_issue_5097-2.odin $COMMON $ODIN build ../test_issue_5265.odin $COMMON +$ODIN test ../test_issue_5699.odin $COMMON set +x diff --git a/tests/issues/test_issue_5699.odin b/tests/issues/test_issue_5699.odin new file mode 100644 index 000000000..cc91799e1 --- /dev/null +++ b/tests/issues/test_issue_5699.odin @@ -0,0 +1,36 @@ +// Tests issue #5699 https://github.com/odin-lang/Odin/issues/5699 +package test_issues + +import "core:testing" + +Issue5699_Value :: struct { + value: i32, +} + +Issue5699_Result :: union { + Issue5699_Value, +} + +test_issue_5699_increment_union :: proc(counter: ^i32) -> Issue5699_Result { + counter^ += 1 + return Issue5699_Value{0} +} + +@test +test_issue_5699_union :: proc(t: ^testing.T) { + counter: i32 = 0 + _ = test_issue_5699_increment_union(&counter).(Issue5699_Value).value + testing.expectf(t, counter == 1, "\n\texpected: 1\n\tgot: %d", counter) +} + +test_issue_5699_increment_any :: proc(counter: ^i32) -> any { + counter^ += 1 + return Issue5699_Value{0} +} + +@test +test_issue_5699_any :: proc(t: ^testing.T) { + counter: i32 = 0 + _ = test_issue_5699_increment_any(&counter).(Issue5699_Value).value + testing.expectf(t, counter == 1, "\n\texpected: 1\n\tgot: %d", counter) +} |