[Issue 8402] Lambda argument's default value is not taken into account
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Aug 4 10:11:18 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8402
--- Comment #5 from Kenji Hara <k.hara.pg at gmail.com> 2012-08-04 10:11:15 PDT ---
(In reply to comment #0)
> The following code does not compile (x.d):
>
> void main()
> {
> auto fn = (int x = 0) => x + 1;
> fn();
> }
>
> with message: "x.d(4): Error: expected 1 function arguments, not 0"
> However, calling fn() with an explicit argument works fine as usual.
The function pointer `fn` is not a lambda itself, so cannot have default
argument.
If it is allowed:
auto fn = (int x = 0) => x + 1;
fn(); // returns 1
fn = (int x = 1) => x + 1;
fn(); // returns 1 or 2?
What is returned by the 2nd call of fn? I cannot imagine it.
--
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