From e3d6fe72f8c7c79a09e18ba089552b7f6235c52b Mon Sep 17 00:00:00 2001 From: Louis Novy <101842021+louisnovy@users.noreply.github.com> Date: Sun, 1 Mar 2026 20:58:43 -0800 Subject: [PATCH 1/3] fix broken bit_set parapoly specialization #6240 --- src/check_expr.cpp | 5 +++++ src/check_type.cpp | 1 + tests/issues/run.bat | 1 + tests/issues/run.sh | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 1cf133f38..7f0acb4c6 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1501,6 +1501,11 @@ gb_internal bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, T case Type_BitSet: if (source->kind == Type_BitSet) { + if (!is_type_polymorphic(poly->BitSet.elem)) { + if (poly->BitSet.upper != source->BitSet.upper || poly->BitSet.lower != source->BitSet.lower) { + return false; + } + } if (!is_polymorphic_type_assignable(c, poly->BitSet.elem, source->BitSet.elem, true, modify_type)) { return false; } diff --git a/src/check_type.cpp b/src/check_type.cpp index b1d0045e9..82e70dd33 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1229,6 +1229,7 @@ gb_internal void check_bit_set_type(CheckerContext *c, Type *type, Type *named_t ast_node(bs, BitSetType, node); GB_ASSERT(type->kind == Type_BitSet); type->BitSet.node = node; + type->BitSet.elem = t_invalid; /* i64 const DEFAULT_BITS = cast(i64)(8*build_context.word_size); */ i64 const MAX_BITS = 128; diff --git a/tests/issues/run.bat b/tests/issues/run.bat index f17f646a6..de380e313 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -29,6 +29,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused ..\..\..\odin test ..\test_issue_6068.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_6101.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_6165.odin %COMMON% || exit /b +..\..\..\odin build ..\test_issue_6240.odin %COMMON% 2>&1 | find /c "Error:" | findstr "3" || exit /b @echo off diff --git a/tests/issues/run.sh b/tests/issues/run.sh index 73d0d9587..6c6796e28 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -36,6 +36,12 @@ $ODIN test ../test_issue_5699.odin $COMMON $ODIN test ../test_issue_6068.odin $COMMON $ODIN test ../test_issue_6101.odin $COMMON $ODIN test ../test_issue_6165.odin $COMMON +if [[ $($ODIN build ../test_issue_6240.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 3 ]] ; then + echo "SUCCESSFUL 1/1" +else + echo "SUCCESSFUL 0/1" + exit 1 +fi set +x popd From 1a27af515f2dc431f7593b99d30a49a952486fbb Mon Sep 17 00:00:00 2001 From: Louis Novy <101842021+louisnovy@users.noreply.github.com> Date: Sun, 1 Mar 2026 21:18:30 -0800 Subject: [PATCH 2/3] add test file --- tests/issues/test_issue_6240.odin | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/issues/test_issue_6240.odin diff --git a/tests/issues/test_issue_6240.odin b/tests/issues/test_issue_6240.odin new file mode 100644 index 000000000..a56f44f33 --- /dev/null +++ b/tests/issues/test_issue_6240.odin @@ -0,0 +1,14 @@ +// Tests issue #6240 https://github.com/odin-lang/Odin/issues/6240 +package test_issues + +// should error - N=10 does not match bit_set range 0..<5 +foo :: proc($N: int, b: $B/bit_set[0 ..< N]) {} + +// should error without segfaulting - undefined identifier in bit_set range +bar :: proc(b: $B/bit_set[0 ..< asdf]) {} + +main :: proc() { + b: bit_set[0 ..< 5] + foo(10, b) + bar(bit_set[0 ..< 1]{}) +} From 7732a78c089a39722d9a43cc2cb206080ac028bf Mon Sep 17 00:00:00 2001 From: Louis Novy <101842021+louisnovy@users.noreply.github.com> Date: Sun, 1 Mar 2026 21:33:14 -0800 Subject: [PATCH 3/3] harden run.bat and add missing test_issue_2395 --- tests/issues/run.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/issues/run.bat b/tests/issues/run.bat index de380e313..9e722886d 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -21,6 +21,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused ..\..\..\odin test ..\test_issue_4210.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_4364.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_4584.odin %COMMON% || exit /b +..\..\..\odin build ..\test_issue_2395.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "2" || exit /b ..\..\..\odin build ..\test_issue_5043.odin %COMMON% || exit /b ..\..\..\odin build ..\test_issue_5097.odin %COMMON% || exit /b ..\..\..\odin build ..\test_issue_5097-2.odin %COMMON% || exit /b @@ -29,7 +30,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused ..\..\..\odin test ..\test_issue_6068.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_6101.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_6165.odin %COMMON% || exit /b -..\..\..\odin build ..\test_issue_6240.odin %COMMON% 2>&1 | find /c "Error:" | findstr "3" || exit /b +..\..\..\odin build ..\test_issue_6240.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "3" || exit /b @echo off