D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20761 - __traits(isSame) for alias tuples is broken and underspecified
Summary: __traits(isSame) for alias tuples is broken and underspecified
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: basile-z
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-04-23 07:04 UTC by Max Samukha
Modified: 2020-07-09 01:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2020-04-23 07:04:34 UTC
// 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 basile-z 2020-07-04 20:07:25 UTC
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 Dlang Bot 2020-07-04 21:10:11 UTC
@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 Dlang Bot 2020-07-08 13:10:32 UTC
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 Dlang Bot 2020-07-09 01:20:33 UTC
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