[Issue 21889] __traits(isSame, Object, const Object) yields true

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 26 05:26:32 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=21889

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla at digitalmars.com
         Resolution|---                         |WONTFIX

--- Comment #2 from Walter Bright <bugzilla at digitalmars.com> ---
The documentation says:

"The result is true if the two arguments are the same symbol (once aliases are
resolved)."

  -- https://dlang.org/spec/traits.html#isSame

The code is behaving as specified, as Object and const(Object) are indeed the
same symbol.

But they are different types. To compare types, use

```
is(Object == const(Object))
```
or:
```
is(Object : const(Object))
```

There isn't a need to change anything. Use `is` if comparing types,
`traits(isSame)` for comparing symbols.

--


More information about the Digitalmars-d-bugs mailing list