[Issue 9992] New: Default argument from member variable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 25 19:54:36 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9992

           Summary: Default argument from member variable
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: luismarques at gmail.com


--- Comment #0 from Luís Marques <luismarques at gmail.com> 2013-04-25 19:54:34 PDT ---
In DMD64 v2.062, if you define a method with a default argument from a member
variable, DMD only complains if the method is actually called:

    class Foo
    {
        int a = 0;

        void bar(int x = a)
        {
        }
    }

    void main()
    {
        Foo f = new Foo();
        //f.bar();   -> does not complain with this commented out
    }

With the method call it produces the error "need 'this' to access member a",
which seems to be the defined behavior (but why not allow the default argument
to be variable? you can just read 'a' and push it on the stack).

-- 
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