[Issue 4246] New: Delegate literals passed to variadic templates function incorrectly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri May 28 14:17:49 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4246
Summary: Delegate literals passed to variadic templates
function incorrectly
Product: D
Version: future
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P3
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: sandford at jhu.edu
--- Comment #0 from Rob Jacques <sandford at jhu.edu> 2010-05-28 14:17:47 PDT ---
I found this while playing with delegate literals and map. Thankfully, map and
non-variadic templates don't compile with delegate literals, but this example
does:
import std.stdio: writeln;
import std.range;
import std.algorithm;
template bar(fun...) {
auto bar(int[] r) {
return fun[0](r.front);
}
}
void main(string[] args) {
int[] x = [1,2,3,4,5];
int y = 6;
auto dg = (int t){ return t + y; };
auto list = bar!( dg )(x);
auto list2 = bar!( (int t){ return t + y; } )(x);
writeln(list,'\t',list2);
return;
}
This prints out the correct value (7) when a delegate is passed in, but the
delegate literal call results in a random printed number.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list