D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22149 - TypeInfo_Struct names aren't unique, leading to botched equality semantics
Summary: TypeInfo_Struct names aren't unique, leading to botched equality semantics
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-07-27 11:19 UTC by kinke
Modified: 2021-08-01 12:04 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kinke 2021-07-27 11:19:20 UTC
```
struct Foo(T) {}

void main()
{
    auto foo()
    {
        struct S {}
        return Foo!S();
    }

    auto bar()
    {
        struct S {}
        return Foo!S();
    }

    auto f = foo();
    auto b = bar();

    // both fail:
    assert(typeid(f) != typeid(b));
    assert(typeid(f).name != typeid(b).name);
}
```

[TypeInfo_Class names aren't unique either, will file an extra issue about that.]
Comment 1 Dlang Bot 2021-07-27 11:33:33 UTC
@kinke updated dlang/dmd pull request #12928 "TypeInfo_Struct: Switch to stored mangled name" fixing this issue:

- Fix Issue 22149 - TypeInfo_Struct names aren't unique, leading to botched equality semantics
  
  By storing the mangled name, making the TypeInfo_Struct names truly
  unique and more compact at the same time.
  Requires https://github.com/dlang/druntime/pull/3527.

https://github.com/dlang/dmd/pull/12928
Comment 2 Dlang Bot 2021-08-01 12:04:32 UTC
dlang/dmd pull request #12928 "Fix Issues 22149 & 22150 - TypeInfo names aren't unique, leading to botched equality semantics" was merged into master:

- 65fc66a4583069bfe767d1c28850cdab364ae282 by Martin Kinkelin:
  Fix Issue 22149 - TypeInfo_Struct names aren't unique, leading to botched equality semantics
  
  By storing the mangled name, making the TypeInfo_Struct names truly
  unique and more compact at the same time.
  Requires https://github.com/dlang/druntime/pull/3527.

https://github.com/dlang/dmd/pull/12928