Bug 20761 – __traits(isSame) for alias tuples is broken and underspecified
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-04-23T07:04:34Z
Last change time
2020-07-09T01:20:33Z
Keywords
pull
Assigned to
Basile-z
Creator
Max Samukha
Comments
Comment #0 by maxsamukha — 2020-04-23T07:04:34Z
// fails
static assert(__traits(isSame, AliasSeq!(1, 2), AliasSeq!(1, 2)));
// passes
static assert(__traits(isSame, AliasSeq!(1, 1), AliasSeq!(1, 1)));
If the tuples are meant to expand, then both assertions should fail with a "wrong number of arguments" error. Otherwise, both assertion should pass.
To me, the most consistent semantics would be for __traits(isSame) to behave as a template with two alias parameters (it would be necessary to nest tuples in another template before passing them to __traits(isSame)).
Comment #1 by b2.temp — 2020-07-04T20:07:25Z
this is a cool bug. The fact that this 3rd case passes explains it all:
static assert(__traits(isSame, AliasSeq!(1, 1), AliasSeq!(2, 2)));
in traits semantic, the two args are actually a list that expands in place to (1,1,2,2) and finally what get compared is the two elements of what was the first trait argument !
awesome bug isn't it !!
Comment #2 by dlang-bot — 2020-07-04T21:10:11Z
@NilsLankila created dlang/dmd pull request #11373 "fix issue 20761 - __traits(isSame) for alias tuples is broken and und…" fixing this issue:
- fix issue 20761 - __traits(isSame) for alias tuples is broken and underspecified
https://github.com/dlang/dmd/pull/11373
Comment #3 by dlang-bot — 2020-07-08T13:10:32Z
dlang/dmd pull request #11373 "fix issue 20761 - __traits(isSame) for alias tuples is broken and und…" was merged into master:
- c8b470c05b001853f83cbf1b5d9e0e66ef1b2ca4 by Nils Lankila:
fix issue 20761 - __traits(isSame) for alias tuples is broken and underspecified
https://github.com/dlang/dmd/pull/11373
Comment #4 by dlang-bot — 2020-07-09T01:20:33Z
dlang/dmd pull request #11392 "Add tests for issue 20761 - __traits(isSame) for alias tuples..." was merged into master:
- 5f68732fe07f981f0359f665930dfb852367ac29 by MoonlightSentinel:
Add tests for issue 20761 - __traits(isSame) for alias tuples...
... is brokenand underspecified
https://github.com/dlang/dmd/pull/11392