www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13845] New: std.variant.Algebraic "__lambda2 is not a

https://issues.dlang.org/show_bug.cgi?id=13845

          Issue ID: 13845
           Summary: std.variant.Algebraic "__lambda2 is not a function or
                    delegate" when using alias vs. bare type
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: monkeyworks12 hotmail.com

import std.variant;
import std.stdio;

alias Null = typeof(null);

alias Maybe(T) = Algebraic!(T, typeof(null));

void main()
{
    Maybe!int n = 0;
    writeln(n); //Prints "0"

    //Prints "I'm Null!"
    n.visit!(
        (int) => writeln("I'm an int!"),

        //Ok
        (typeof(null)) => writeln("I'm Null!"),

        //std/variant.d(1966): Error: static assert "__lambda2 is not a 
        //function or delegate"
/opt/compilers/dmd2/include/std/variant.d(1766):
        //instantiated from here: 
        //visitImpl!(true, 
        //        VariantN!(8LU, int, typeof(null)), 
        //        function (int _param_0)
        //(Null) => writeln("I'm Null!"),
    );
}

--
Dec 09 2014