Bug 11853 – Tuples fail "isAssignable"

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-31T04:00:00Z
Last change time
2013-12-31T14:03:56Z
Assigned to
nobody
Creator
monarchdodra

Comments

Comment #0 by monarchdodra — 2013-12-31T04:00:39Z
Works in 2.064.2. Fails in master: //---- import std.traits, std.typecons; void main() { alias T = Tuple!int; static assert(isAssignable!T); } //---- main.d(6): Error: static assert (isAssignable!(Tuple!int)) is false //----
Comment #1 by monarchdodra — 2013-12-31T08:17:41Z
According to "dissect", the faulty commit is: Fix swap for non-assignable: https://github.com/D-Programming-Language/phobos/commit/97e1fb80d404899cc14d03483f61986791747e38#diff-ff74a46362b5953e8c88120e2490f839 Which added this static test in "swap": static if (!isAssignable!T || hasElaborateAssign!T) The bummer is that tuple's opAssign looks like: void opAssign(R)(auto ref R rhs) if (areCompatibleTuples!(typeof(this), R, "=")) { import std.algorithm : swap; swap!(Tuple!Types)(this, rhs); I'm not quite sure *how* the compiler resolves that: 1. To instantiate opAssign, we need swap... 2. For swap we need to know if assignable... 3. To know if assignable, we need to instantiate opAssign... In particular, it gives "funny" scenarios such as: //---- alias T = Tuple!int; void main() { T t; static assert(isAssignable!T); //FAILS } //---- alias T = Tuple!int; void main() { T t; t = T.init; static assert(isAssignable!T); //PASSES } //---- We can workaround the problem by checking "hasElaborateAssign" first, as that check does not actually look into the implementation. Still, there is some bad smell here.
Comment #2 by github-bugzilla — 2013-12-31T10:22:14Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/5d583483e3a997562d036dac872ae8548e73483f fix Issue 11853 - Tuples fail "isAssignable" https://github.com/D-Programming-Language/phobos/commit/327085b8fed061853b0a9c8bdc42df9e495d0315 Merge pull request #1826 from monarchdodra/11853 fix Issue 11853 - Tuples fail "isAssignable"