From ff02184b2e0beebeb5d0bbc3ce86bf78e583d28f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 2 Oct 2026 16:42:33 +0100 Subject: [PATCH] Fix #7708: compare a polymorphic record's constant parameters by value in `subst_unify` --- src/check_type.cpp | 5 +++++ tests/issues/run.bat | 2 ++ tests/issues/run.sh | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/src/check_type.cpp b/src/check_type.cpp index d04fbfe8e..8555140cc 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -2127,6 +2127,11 @@ gb_internal SubstResult subst_unify(CheckerContext *c, Type *pattern, Type *sour if (r != Subst_Matched) { return r; // NoMatch or Unhandled } + // e.g. `M(1, 1, $T)` vs `M(3, 3, f64)` + if (s_e->kind == Entity_Constant && t_e->kind == Entity_Constant && + !compare_exact_values(Token_CmpEq, s_e->Constant.value, t_e->Constant.value)) { + return Subst_NoMatch; + } } } return Subst_Matched; diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 2c2004955..1c68c582d 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -84,6 +84,8 @@ clang -c ..\test_issue_sysv_abi.c -o test_issue_sysv_abi_c.o || exit /b ..\..\..\odin test ..\test_issue_7316.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_7566.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_poly_using_subtype.odin %COMMON% || exit /b +..\..\..\odin test ..\test_issue_7708.odin %COMMON% || exit /b +..\..\..\odin check ..\test_issue_7708_mismatch.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "2" || exit /b ..\..\..\odin test ..\test_issue_7587.odin %COMMON% || exit /b ..\..\..\odin run ..\test_issue_7596.odin %COMMON% || exit /b diff --git a/tests/issues/run.sh b/tests/issues/run.sh index fb50f87cd..e8912b635 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -105,6 +105,13 @@ $ODIN run ../test_issue_7564.odin $COMMON $ODIN test ../test_issue_7316.odin $COMMON $ODIN test ../test_issue_7566.odin $COMMON $ODIN test ../test_issue_poly_using_subtype.odin $COMMON +$ODIN test ../test_issue_7708.odin $COMMON +if [[ $($ODIN check ../test_issue_7708_mismatch.odin $COMMON_CHECK 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]]; then + echo "SUCCESSFUL 1/1" +else + echo "SUCCESSFUL 0/1" + exit 1 +fi $ODIN test ../test_issue_7587.odin $COMMON $ODIN run ../test_issue_7596.odin $COMMON $ODIN test ../test_issue_7421.odin $COMMON