Thread overview
[Issue 8579] New: Default parameter appears a part of typeof().stringof of a function variable
Aug 22, 2012
Ali Cehreli
Aug 22, 2012
Ali Cehreli
Aug 23, 2012
Maxim Fomin
Aug 23, 2012
Ali Cehreli
Sep 06, 2012
Kenji Hara
Jul 04, 2013
Kenji Hara
Jul 04, 2013
Kenji Hara
August 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8579

           Summary: Default parameter appears a part of typeof().stringof
                    of a function variable
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: acehreli@yahoo.com


--- Comment #0 from Ali Cehreli <acehreli@yahoo.com> 2012-08-22 14:23:55 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8579


Ali Cehreli <acehreli@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8579


Maxim Fomin <maxim@maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim@maxim-fomin.ru


--- Comment #1 from Maxim Fomin <maxim@maxim-fomin.ru> 2012-08-22 22:22:47 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8579



--- Comment #2 from Ali Cehreli <acehreli@yahoo.com> 2012-08-22 23:29:58 PDT ---
I think the decision has been made after that discussion:

http://d.puremagic.com/issues/show_bug.cgi?id=3866#c5

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8579


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-09-05 18:53:53 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1102

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 04, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8579


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 04, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8579



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-04 04:54:26 PDT ---
Fixed commit: https://github.com/D-Programming-Language/dmd/commit/a711eb6b499ca85b7cfa4e758d9e968fef8d315f

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------