www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9992] New: Default argument from member variable

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 puremagic.com
        ReportedBy: luismarques gmail.com


--- Comment #0 from Luís Marques <luismarques 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: -------
Apr 25 2013