diff --git a/src/name_canonicalization.cpp b/src/name_canonicalization.cpp index 97f10e0f8..f6243025a 100644 --- a/src/name_canonicalization.cpp +++ b/src/name_canonicalization.cpp @@ -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); diff --git a/tests/issues/run.sh b/tests/issues/run.sh index 98c144d9c..a6e81e9a3 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -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 diff --git a/tests/issues/test_issue_7429.odin b/tests/issues/test_issue_7429.odin new file mode 100644 index 000000000..21e407bed --- /dev/null +++ b/tests/issues/test_issue_7429.odin @@ -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) + } +}