Merge pull request #7439 from ssenthilnathan3/fix/proc-literal-type-canonicalization

Fix canonical names for types in procedure literals
This commit is contained in:
gingerBill
2026-08-25 15:12:32 +01:00
committed by GitHub
3 changed files with 27 additions and 0 deletions

View File

@@ -674,6 +674,17 @@ gb_internal void write_canonical_entity_name(TypeWriter *w, Entity *e) {
write_scope_index_suffix = true;
}
goto write_base_name;
} else if (s->decl_info != nullptr && s->decl_info->proc_lit != nullptr) {
Ast *proc_lit = s->decl_info->proc_lit;
String file_name = filename_without_directory(proc_lit->file()->fullpath);
type_writer_append(w, e->pkg->name.text, e->pkg->name.len);
type_writer_append_fmt(w, CANONICAL_NAME_SEPARATOR CANONICAL_ANON_PREFIX "_%.*s:%d" CANONICAL_NAME_SEPARATOR,
LIT(file_name), ast_token(proc_lit).pos.offset);
if (e->scope->index > 0) {
write_scope_index_suffix = true;
}
goto write_base_name;
} else if ((s->flags & ScopeFlag_File) && s->file != nullptr) {
String file_name = filename_without_directory(s->file->fullpath);

View File

@@ -91,6 +91,7 @@ $ODIN check ../test_issue_6979.odin -no-entry-point $COMMON_CHECK
$ODIN test ../test_issue_7008.odin $COMMON
$ODIN check ../test_issue_7012.odin -no-entry-point $COMMON_CHECK
$ODIN build ../test_issue_7037.odin $COMMON -o:none
$ODIN check ../test_issue_7429.odin $COMMON_CHECK
$ODIN test ../test_issue_7356.odin $COMMON
$ODIN build ../test_issue_7167.odin $COMMON
$ODIN build ../test_issue_7188.odin $COMMON

View File

@@ -0,0 +1,15 @@
// Tests issue #7429: local distinct types in procedure literal values must have
// unique canonical names.
// https://github.com/odin-lang/Odin/issues/7429
package test_issues
main :: proc() {
_ = proc() {
Foo :: distinct string
_ = typeid_of(Foo)
}
_ = proc() {
Foo :: distinct string
_ = typeid_of(Foo)
}
}