http://d.puremagic.com/issues/show_bug.cgi?id=3866
Summary: anonymous delegate with default parameters cross-talks
to another anonymous delegate
Product: D
Version: 2.040
Platform: Other
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Philippe Sigaud <[email protected]> 2010-03-01
18:36:25 CET ---
If you declare an anonymous delegate with default parameter, it affects another
anonymous delegate with the same type:
import std.stdio;
void main() {
auto foo = (int a = 1) { return a;};
auto bar = (int a) { return a;};
writeln(foo()); // writes '1'
writeln(bar()); // writes '1' also!
}
It provokes (correctly) an error if bar is defined before foo: bar() called
with 0 argument instead of 1.
It does not affect delegate with another type
auto baz = (double a) { return a;};
writeln(baz()); // Error, correct behaviour
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------