Bug 15168 – [REG2.068.0] std.variant.Algebraic interacts badly with string alias this sub-types

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2015-10-06T07:00:00Z
Last change time
2015-11-13T13:15:50Z
Keywords
pull
Assigned to
nobody
Creator
radu.racariu

Comments

Comment #0 by radu.racariu — 2015-10-06T07:00:27Z
When sub-typing a string via alias this, the Algebraic construct fails to distinguish the sub-type from the string type. Using the following: -------------------------------------------- import std.variant : Algebraic; struct N { double val; alias val this; } struct S { string val; alias val this; } alias T = Algebraic!(S, N); pragma(msg, T.AllowedTypes); -------------------------------------------- prints (N, string) This happens in v2.068.2 win32 The expected behavior is to have S as a allowed type instead of string. A workaround is to use std.typecons.Proxy in the S type. Like: struct S { /// the value string val; this(string s) { this.val = s; } import std.typecons : Proxy; mixin Proxy!val; }
Comment #1 by dlang-bugzilla — 2015-10-15T19:33:01Z
This seems to be a regression. Introduced in https://github.com/D-Programming-Language/phobos/pull/3394
Comment #2 by code — 2015-10-27T14:42:40Z
Is this a duplicate of issue 15039?
Comment #3 by dlang-bugzilla — 2015-10-27T15:13:52Z
Yes, confirmed fixed in stable. *** This issue has been marked as a duplicate of issue 15039 ***
Comment #4 by dlang-bugzilla — 2015-10-27T15:15:26Z
Grr, sorry. No it's not. I tested the wrong bug.
Comment #5 by code — 2015-10-28T09:32:47Z
cat > bug.d << CODE import std.typecons; struct S { string val; alias val this; } pragma(msg, ReplaceType!(int, int, S)); static assert(is(ReplaceType!(int, int, S) == S)); CODE dmd -c bug ---- string bug2.d(5): Error: static assert (is(string == S)) is false ----
Comment #6 by code — 2015-10-28T09:55:55Z
Comment #7 by code — 2015-10-28T11:01:05Z
The underlying cause is a compiler bug, see issue 15254.
Comment #8 by github-bugzilla — 2015-10-29T10:00:47Z
Commits pushed to stable at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/17af3b3014c625b23619fed11b68bbeb62b06e2c fix Issue 15168 - ReplaceType broken for string sub-types https://github.com/D-Programming-Language/phobos/commit/474eaff973887b8cce46b3440a1d6fd9426a4558 Merge pull request #3779 from MartinNowak/fix15168 fix Issue 15168 - ReplaceType broken for string sub-types
Comment #9 by github-bugzilla — 2015-10-31T19:20:29Z
Comment #10 by radu.racariu — 2015-11-13T13:15:50Z
Works great in 2.069.1, thanks guys!