www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18831] New: Weird interaction between std.variant,


          Issue ID: 18831
           Summary: Weird interaction between std.variant,
                    std.algorithm.iteration.map, and alias this
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: dhasenan gmail.com

import std.variant, std.range, std.algorithm;

struct Bar
    int i;

struct Foo
    auto i()
        return iota(12)
            .map!(x => Bar(x));
    alias i this;

void main()
    Foo controlGroup = Foo();
    Algebraic!(Foo) treatmentGroup = Foo();

The control group works without errors. The treatment group fails with:

/home/dhasenan/.local/bin/../include/phobos/std/meta.d(799): Error: template
instance `F!(__lambda1)` cannot use local __lambda1 as parameter to non-global
template replaceTemplateArgs(T...)
/home/dhasenan/.local/bin/../include/phobos/std/meta.d(805): Error: template
instance `algebraicaliasthis.Foo.i.staticMap!(replaceTemplateArgs, __lambda1)`
error instantiating
instantiated from here: staticMap!(replaceTemplateArgs, __lambda1, Result)
instantiated from here: ReplaceType!(This, VariantN!(1LU, Foo), Foo)
instantiated from here: This2Variant!(VariantN!(1LU, Foo), Foo)
instantiated from here: VariantN!(1LU, Foo)
algebraicaliasthis.d(20):        instantiated from here: Algebraic!(Foo)

May 05 2018