Bug 12520 – Comparing two TypeTuples with == does not compile for no arguments

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-04T06:37:40Z
Last change time
2020-05-25T09:25:40Z
Keywords
pull
Assigned to
No Owner
Creator
Simen Kjaeraas

Comments

Comment #0 by simen.kjaras — 2014-04-04T06:37:40Z
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 by dlang-bot — 2020-05-24T17:30:58Z
@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 by dlang-bot — 2020-05-25T09:25:40Z
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