From 90e7fd0ab4f227cbd965e85d85c1e01e39c4061f Mon Sep 17 00:00:00 2001 From: Cauterite Date: Sun, 14 Aug 2016 04:21:31 +1000 Subject: [PATCH 1/3] fix Issue 16383 - 'Algebraic visit does not match const' --- std/variant.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/variant.d b/std/variant.d index 1235895e80d..b61474f48fc 100644 --- a/std/variant.d +++ b/std/variant.d @@ -2209,7 +2209,7 @@ private auto visitImpl(bool Strict, VariantType, Handler...)(VariantType variant result.exceptionFuncIdx = dgidx; } } - else static if (is(Unqual!(Params[0]) == T)) + else static if (is(Params[0] == T) || is(Unqual!(Params[0]) == T)) { if (added) assert(false, "duplicate overload specified for type '" ~ T.stringof ~ "'"); From a63348d8c2edc42bca3cddb974466f7a5d95b805 Mon Sep 17 00:00:00 2001 From: Cauterite Date: Mon, 15 Aug 2016 21:12:15 +1000 Subject: [PATCH 2/3] unittest for variant bug 16383 --- std/variant.d | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/std/variant.d b/std/variant.d index b61474f48fc..06fe5c41882 100644 --- a/std/variant.d +++ b/std/variant.d @@ -2293,6 +2293,18 @@ unittest assert(depth(fb) == 3); } +unittest +{ + // https://issues.dlang.org/show_bug.cgi?id=16383 + class Foo {this() immutable {}}; + alias V = Algebraic!(immutable Foo); + + auto x = V(new immutable Foo).visit!( + (immutable(Foo) _) => 3 + ); + assert(x == 3); +} + unittest { // http://d.puremagic.com/issues/show_bug.cgi?id=5310 From 8b50e1359e46d70c89a6151530f3b75a29f9338b Mon Sep 17 00:00:00 2001 From: Cauterite Date: Mon, 15 Aug 2016 21:24:24 +1000 Subject: [PATCH 3/3] Update variant.d --- std/variant.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/variant.d b/std/variant.d index 06fe5c41882..b160a264ae7 100644 --- a/std/variant.d +++ b/std/variant.d @@ -2296,7 +2296,7 @@ unittest unittest { // https://issues.dlang.org/show_bug.cgi?id=16383 - class Foo {this() immutable {}}; + class Foo {this() immutable {}} alias V = Algebraic!(immutable Foo); auto x = V(new immutable Foo).visit!(