mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-31 19:28:55 +00:00
fix: hang for poly procs with default proc literal params
This commit is contained in:
@@ -6735,8 +6735,11 @@ gb_internal bool consume_proc_info(Checker *c, ProcInfo *pi, UntypedExprInfoMap
|
||||
// This is prevent any possible race conditions in evaluation when multithreaded
|
||||
// NOTE(bill): In single threaded mode, this should never happen
|
||||
if (parent->kind == Entity_Procedure && (parent->flags & EntityFlag_ProcBodyChecked) == 0) {
|
||||
check_procedure_later(c, pi);
|
||||
return false;
|
||||
Type *pt = base_type(parent->type);
|
||||
if (!pt->Proc.is_polymorphic || pt->Proc.is_poly_specialized) {
|
||||
check_procedure_later(c, pi);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (untyped) {
|
||||
@@ -6770,8 +6773,11 @@ gb_internal WORKER_TASK_PROC(check_proc_info_worker_proc) {
|
||||
// This is prevent any possible race conditions in evaluation when multithreaded
|
||||
// NOTE(bill): In single threaded mode, this should never happen
|
||||
if (parent->kind == Entity_Procedure && (parent->flags & EntityFlag_ProcBodyChecked) == 0) {
|
||||
thread_pool_add_task(check_proc_info_worker_proc, pi);
|
||||
return 1;
|
||||
Type *pt = base_type(parent->type);
|
||||
if (!pt->Proc.is_polymorphic || pt->Proc.is_poly_specialized) {
|
||||
thread_pool_add_task(check_proc_info_worker_proc, pi);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
map_clear(untyped);
|
||||
|
||||
@@ -32,6 +32,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused
|
||||
..\..\..\odin test ..\test_issue_6165.odin %COMMON% || exit /b
|
||||
..\..\..\odin build ..\test_issue_6240.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "3" || exit /b
|
||||
..\..\..\odin build ..\test_issue_6401.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "3" || exit /b
|
||||
..\..\..\odin test ..\test_issue_6419.odin %COMMON% || exit /b
|
||||
..\..\..\odin test ..\test_pr_6470.odin %COMMON% || exit /b
|
||||
..\..\..\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
|
||||
|
||||
@@ -65,6 +65,7 @@ else
|
||||
echo "SUCCESSFUL 0/1"
|
||||
exit 1
|
||||
fi
|
||||
$ODIN test ../test_issue_6419.odin $COMMON
|
||||
$ODIN test ../test_pr_6470.odin $COMMON
|
||||
if [[ $($ODIN test ../test_pr_6470.odin -define:TEST_EXPECT_FAILURE=true $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]] ; then
|
||||
echo "SUCCESSFUL 1/1"
|
||||
|
||||
40
tests/issues/test_issue_6419.odin
Normal file
40
tests/issues/test_issue_6419.odin
Normal file
@@ -0,0 +1,40 @@
|
||||
// Tests issue #6419 https://github.com/odin-lang/Odin/issues/6419
|
||||
// A polymorphic procedure with default procedure literal parameters
|
||||
// should not cause the compiler to hang.
|
||||
package test_issues
|
||||
|
||||
import "core:testing"
|
||||
|
||||
// The proc that triggered the hang: polymorphic pointer param + default proc() {} params
|
||||
undo_push :: proc(data: ^$T, undo_proc := proc() {}, redo_proc := proc() {}) {}
|
||||
|
||||
// Sanity check: non-polymorphic version still works
|
||||
undo_push_int :: proc(data: ^int, undo_proc := proc() {}, redo_proc := proc() {}) {}
|
||||
|
||||
// Sanity check: non-polymorphic without pointer still works
|
||||
undo_push_no_ptr :: proc(data: int, undo_proc := proc() {}, redo_proc := proc() {}) {}
|
||||
|
||||
// Sanity check: no data param at all still works
|
||||
undo_push_no_data :: proc(undo_proc := proc() {}, redo_proc := proc() {}) {}
|
||||
|
||||
@(test)
|
||||
test_issue_6419_polymorphic_default_proc_params :: proc(t: ^testing.T) {
|
||||
hey: int = 5
|
||||
undo_push(&hey)
|
||||
undo_push(&hey, proc() {}, proc() {})
|
||||
undo_push(
|
||||
&hey,
|
||||
proc() {},
|
||||
proc() {
|
||||
// non-empty body
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_issue_6419_non_polymorphic_sanity :: proc(t: ^testing.T) {
|
||||
x: int = 10
|
||||
undo_push_int(&x)
|
||||
undo_push_no_ptr(42)
|
||||
undo_push_no_data()
|
||||
}
|
||||
Reference in New Issue
Block a user