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