Bug 17872 – 'lazy' on variadic template parameters is ignored

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2017-10-02T06:55:08Z
Last change time
2017-10-02T13:44:56Z
Assigned to
No Owner
Creator
Simen Kjaeraas

Comments

Comment #0 by simen.kjaras — 2017-10-02T06:55:08Z
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.
Comment #1 by dunkyp — 2017-10-02T10:58:35Z
Doesn't fail for me with dmd v2.076 on MacOS
Comment #2 by simen.kjaras — 2017-10-02T13:44:56Z
You're right, I've misidentified the problem. This fails: void foo(T...)(lazy T args) { foreach (e; args) {} } unittest { int n = 3; foo(n++); assert(n == 3); } Which means the problem is not in the location I thought.