D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12520 - Comparing two TypeTuples with == does not compile for no arguments
Summary: Comparing two TypeTuples with == does not compile for no arguments
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2014-04-04 06:37 UTC by Simen Kjaeraas
Modified: 2020-05-25 09:25 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 Simen Kjaeraas 2014-04-04 06:37:40 UTC
assert(TypeTuple!1 == TypeTuple!1);
    assert(TypeTuple!("foo", 12.6) == TypeTuple!("foo", 12.6));

These lines compile. This line does not:

    assert(TypeTuple!() == TypeTuple());

The error message is:

    Error: incompatible types for ((()) == (())): cannot use '==' with types

In the case of generic code, this is problematic - if I have a type that can take a variable number of arguments that are all required to be values, not types, I have to special case comparison of empty args, or resort to weird tricks like using a templated wrapper struct and comparing the types of two wrappers:

    struct CMP(T...){}

    assert(is(CMP!args1 == CMP!args2));
Comment 1 Dlang Bot 2020-05-24 17:30:58 UTC
@NilsLankila created dlang/dmd pull request #11187 "fix issue 12520 - allow comparison of empty tuples to tuples that con…" fixing this issue:

- fix issue 12520 - allow comparison of empty tuples to tuples that contain values
  
  Empty tuples are represented as `TypeTuple` while tuples containing values as `TupleExp`.
  As a consequence, comparing them using `==` was not allowed.

https://github.com/dlang/dmd/pull/11187
Comment 2 Dlang Bot 2020-05-25 09:25:40 UTC
dlang/dmd pull request #11187 "fix issue 12520 - allow comparison of empty tuples to tuples that con…" was merged into stable:

- 078d9e6456672f85ecdaae0f81336c78b70e4980 by Nils Lankila:
  fix issue 12520 - allow comparison of empty tuples to tuples that contain values
  
  Empty tuples are represented as `TypeTuple` while tuples containing values as `TupleExp`.
  As a consequence, comparing them using `==` was not allowed.

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