Bug 1396 – lazy void tuple breaks

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-08-02T14:57:00Z
Last change time
2015-06-09T01:31:14Z
Keywords
rejects-valid
Assigned to
nobody
Creator
default_357-line

Comments

Comment #0 by default_357-line — 2007-08-02T14:57:45Z
import std.stdio; template tuple(T...) { alias T tuple; } void test(lazy tuple!(void, void) a) { a[0](); a[1](); } void main() { test(writefln("Hello"), writefln("World")); } Expected: "Hello\nWorld" Resulted: Error: cannot have parameter of type void. Observed: Seems as if the lazy isn't being applied to all the tuple members as it should be. --downs
Comment #1 by default_357-line — 2007-08-02T15:02:57Z
Added comment: Seems to happen whenever the tuple contains at least one void, for every void in the tuple.
Comment #2 by ibisbasenji — 2007-08-02T17:12:17Z
(In reply to comment #0) > import std.stdio; > template tuple(T...) { alias T tuple; } > void test(lazy tuple!(void, void) a) { a[0](); a[1](); } > void main() { test(writefln("Hello"), writefln("World")); } > > Expected: "Hello\nWorld" > Resulted: Error: cannot have parameter of type void. > Observed: Seems as if the lazy isn't being applied to all the tuple members as > it should be. > > --downs > Since 'lazy void' is really shorthand for 'void delegate()' I wouldn't actually have expected 'lazy' to work in this way anyhow... Although it could indeed be useful. Try running it with 'tuple!(lazy void, lazy void) a' and it should work. I consider this an enhancement request, or clarification request, rather than a bug. (It'd be a nice enhancement, though.)
Comment #3 by default_357-line — 2007-08-03T21:52:31Z
(In reply to comment #2) > Since 'lazy void' is really shorthand for 'void delegate()' I wouldn't actually > have expected 'lazy' to work in this way anyhow... Works with int. gentoo-pc ~/d $ cat bug.d && echo ---- && gdc bug.d -o bug && ./bug import std.stdio; template tuple(T...) { alias T tuple; } void test(lazy tuple!(int, int) a) { writefln("Eval now"); writefln(a[0], "-", a[1]); } void main() { test({writefln("Hello"); return 1; }(), {writefln("World"); return 2; }()); } ---- Eval now World Hello 1-2 > Although it could indeed be > useful. Try running it with 'tuple!(lazy void, lazy void) a' and it should > work. > > I consider this an enhancement request, or clarification request, rather than a > bug. (It'd be a nice enhancement, though.) > import std.stdio; template tuple(T...) { alias T tuple; } void test(tuple!(lazy void, lazy void) a) { a[0](); a[1](); } void main() { test(writefln("Hello"), writefln("World")); } gentoo-pc ~/d $ gdc bug.d -o bug bug.d:3: expression expected, not 'lazy' Thanks for the suggestion, though. --downs
Comment #4 by clugdbug — 2010-01-15T05:28:50Z
Fixed DMD1.054.