Bug 8579 – Default parameter appears a part of typeof().stringof of a function variable

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-08-22T14:23:00Z
Last change time
2013-07-04T04:54:26Z
Keywords
pull
Assigned to
nobody
Creator
acehreli

Comments

Comment #0 by acehreli — 2012-08-22T14:23:55Z
This is related to bug 3866. import std.stdio; void func1(int i, double j = 1.0) { } void func2(int i, double j) { } void main() { auto fn1 = &func1; auto fn2 = &func2; assert(typeid(fn1) is typeid(fn2)); // Passes; fine. writeln(typeof(fn1).stringof); writeln(typeof(fn2).stringof); } The output includes the default value and for *both* of the variables: void function(int i, double j = 1) void function(int i, double j = 1) Interestingly, swap the definitions of fn1 and fn2, now neither has the default parameter value: auto fn2 = &func2; auto fn1 = &func1; Now the output: void function(int i, double j) void function(int i, double j) Ali
Comment #1 by maxim — 2012-08-22T22:22:47Z
Here was a discussion (http://www.digitalmars.com/d/archives/digitalmars/D/What_to_do_about_default_function_arguments_164993.html) but seems the decision about default arguments was not made.
Comment #2 by acehreli — 2012-08-22T23:29:58Z
I think the decision has been made after that discussion: http://d.puremagic.com/issues/show_bug.cgi?id=3866#c5
Comment #3 by k.hara.pg — 2012-09-05T18:53:53Z
Comment #4 by k.hara.pg — 2013-07-04T04:54:26Z