www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17872] New: 'lazy' on variadic template parameters is ignored

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

          Issue ID: 17872
           Summary: 'lazy' on variadic template parameters is ignored
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

This assert fails:

void foo(T...)(lazy T args) {}

unittest {
    int n = 3;
    foo(n++);
    assert(n == 3); // Fails, n == 4.
}

This means there is no way to mark an arbitrary number of arguments of unknown
types as lazy. A workaround exists for limited numbers, where (T1, T2, T3) is
used in place of T..., but this solution does not scale.

--
Oct 01