[Issue 15039] New: Algebraic cannot store a Typedef along with Typedef'ed type
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Sep 11 06:54:54 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15039
Issue ID: 15039
Summary: Algebraic cannot store a Typedef along with Typedef'ed
type
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: kolos80 at bk.ru
Reproducible with dmd v2.068.1
Test case:
// --------------------
import std.variant;
import std.typecons;
alias IntTypedef = Typedef!int;
alias Obj = Algebraic!(int, IntTypedef, This[]);
void x(Obj obj)
{
obj.visit!(
(int x) => {},
(IntTypedef x) => {},
(Obj[] x) => {},
);
}
void main(){}
// --------------------
Produces the following error:
/usr/include/dmd/phobos/std/variant.d(2266,21): Error: static assert "overload
for type 'This[]' hasn't been specified"
/usr/include/dmd/phobos/std/variant.d(2010,54): instantiated from here:
visitImpl!(true, VariantN!(16LU, int, Typedef!(int, 0, null), This[]), function
(int x) => ()
{
}
, function (Typedef!(int, 0, null) x) => ()
{
}
, function (VariantN!(16LU, int, Typedef!(int, 0, null), This[])[] x) => ()
{
}
)
src/app.d(9,8): instantiated from here: visit!(VariantN!(16LU, int,
Typedef!(int, 0, null), This[]))
dmd failed with exit code 1.
However the following code (just without Typedef) compiles just fine:
// --------------------
import std.variant;
import std.typecons;
alias IntTypedef = Typedef!int;
alias Obj = Algebraic!(int, This[]);
void x(Obj obj)
{
obj.visit!(
(int x) => {},
(Obj[] x) => {},
);
}
void main(){}
// --------------------
You can even have Algebraic!(int, int, This[]) without any problems.
--
More information about the Digitalmars-d-bugs
mailing list