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