diff --git a/src/check_expr.cpp b/src/check_expr.cpp index eea6db2b4..115b13992 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1023,17 +1023,6 @@ gb_internal bool check_is_assignable_to_with_score(CheckerContext *c, Operand *o return false; } - // Handle polymorphic procedure used as default parameter - if (operand->mode == Addressing_Value && is_type_proc(type) && is_type_proc(operand->type)) { - Entity *e = entity_from_expr(operand->expr); - if (e != nullptr && e->kind == Entity_Procedure && is_type_polymorphic(e->type) && !is_type_polymorphic(type)) { - // Special case: Allow a polymorphic procedure to be used as default value for concrete proc type - // during the initial check. It will be properly instantiated when actually used. - if (score_) *score_ = assign_score_function(1); - return true; - } - } - i64 score = check_distance_between_types(c, operand, type, allow_array_programming); if (score >= 0) { if (score_) *score_ = assign_score_function(score, is_variadic); diff --git a/tests/issues/run.bat b/tests/issues/run.bat index 8a85ba90a..269c91a0b 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -37,6 +37,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused ..\..\..\odin test ..\test_pr_6470.odin -define:TEST_EXPECT_FAILURE=true %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b ..\..\..\odin test ..\test_pr_6476.odin %COMMON% || exit /b ..\..\..\odin check ..\test_issue_6484.odin -no-entry-point %COMMON% || exit /b +..\..\..\odin test ..\test_issue_6753.odin %COMMON% || exit /b ..\..\..\odin check ..\test_issue_6874.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b ..\..\..\odin check ..\test_issue_6979.odin -no-entry-point %COMMON% || exit /b ..\..\..\odin build ..\test_issue_7037.odin %COMMON% -o:none || exit /b diff --git a/tests/issues/run.sh b/tests/issues/run.sh index ce97a570a..9bcc53dfe 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -74,6 +74,7 @@ else exit 1 fi $ODIN check ../test_issue_6484.odin -no-entry-point $COMMON +$ODIN test ../test_issue_6753.odin -no-entry-point $COMMON if [[ $($ODIN check ../test_issue_6874.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]] ; then echo "SUCCESSFUL 1/1" else diff --git a/tests/issues/test_issue_6753.odin b/tests/issues/test_issue_6753.odin new file mode 100644 index 000000000..7f6c7208c --- /dev/null +++ b/tests/issues/test_issue_6753.odin @@ -0,0 +1,27 @@ +// test issue for #6753 https://github.com/odin-lang/odin/issues/6753 +package test_issues +import "core:testing" + +identity :: proc(x: $T) -> T { return x } + +foo :: proc(x: int, poly: proc(int) -> int = identity) -> int { + return foo(identity(x)) +} + +// failing as returns before specialized +@test +test_issue_6753 :: proc(t: ^testing.T) { + p: proc(int) -> int = identity + + testing.expect(t, p != nil) + + if p != nil { + testing.expect(t, p(123) == 123) + } +} + +// failing as returns before specialized +@test +test_issue_default_poly_parameter_6753 :: proc(t: ^testing.T) { + testing.expect(t, foo(123) == 123) +} \ No newline at end of file