digitalmars.D.bugs - [Issue 15168] New: std.variant.Algebraic interacts badly with string
- via Digitalmars-d-bugs (40/40) Oct 06 2015 https://issues.dlang.org/show_bug.cgi?id=15168
https://issues.dlang.org/show_bug.cgi?id=15168 Issue ID: 15168 Summary: std.variant.Algebraic interacts badly with string alias this sub-types Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: radu.racariu gmail.com 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; } --
Oct 06 2015