[Issue 3866] New: anonymous delegate with default parameters cross-talks to another anonymous delegate
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 1 09:36:26 PST 2010
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: nobody at puremagic.com
ReportedBy: philippe.sigaud at gmail.com
--- Comment #0 from Philippe Sigaud <philippe.sigaud at gmail.com> 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: -------
More information about the Digitalmars-d-bugs
mailing list