Fix the same $ procedure argument generating duplicate instantiations

This commit is contained in:
Louis Novy committed 2026-09-27 10:40:33 -04:00
1 parent 13988d863a
commit fc8b49f5f5
4 files changed
+22 -1

No files matched your search

+3 -1
View File
@@ -2153,7 +2153,9 @@ gb_internal void add_entity_use(CheckerContext *c, Ast *identifier, Entity *enti
if (identifier == nullptr || identifier->kind != Ast_Ident) {
return;
}
entity->identifier.store(identifier);
// NOTE: only set it once, as `$` procedure arguments are matched by this identifier
Ast *empty_ident = nullptr;
entity->identifier.compare_exchange_strong(empty_ident, identifier);
identifier->Ident.entity = entity;
+1
View File
@@ -46,6 +46,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused
..\..\..\odin test ..\test_issue_bool_comparison_truthiness.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_const_array_broadcast.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_forwarded_poly_proc.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_proc_constant_instantiation.odin %COMMON% || exit /b
..\..\..\odin check ..\test_issue_7336.odin -no-entry-point %COMMON% || exit /b
..\..\..\odin check ..\test_issue_ellipsis_type_call.odin -no-entry-point %COMMON% 2>&1 | find /c "Error:" | findstr /x "10" || exit /b
..\..\..\odin check ..\test_issue_foreign_redeclaration.odin -no-entry-point %COMMON% || exit /b
+1
View File
@@ -109,6 +109,7 @@ $ODIN test ../test_issue_bool_to_be_conversion.odin $COMMON
$ODIN test ../test_issue_bool_comparison_truthiness.odin $COMMON
$ODIN test ../test_issue_const_array_broadcast.odin $COMMON
$ODIN test ../test_issue_forwarded_poly_proc.odin $COMMON
$ODIN test ../test_issue_proc_constant_instantiation.odin $COMMON
$ODIN test ../test_issue_swizzle_multi_assign.odin $COMMON
$ODIN check ../test_issue_foreign_redeclaration.odin -no-entry-point $COMMON_CHECK
@@ -0,0 +1,17 @@
package test_issues
import "core:testing"
// Passing the same procedure to a `$` parameter from two calls used to generate two instantiations,
// each with its own `Box` crashing the compiler.
box_of :: proc($f: proc() -> int) -> typeid {
Box :: struct {}
return Box
}
one :: proc() -> int { return 1 }
@(test)
proc_constant_instantiation :: proc(t: ^testing.T) {
testing.expect_value(t, box_of(one), box_of(one))
}