www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9121] New: Templated getters/setter for properties collision

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9121

           Summary: Templated getters/setter for properties collision
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dmitry.olsh gmail.com



05:07:32 PST ---
Sample:

struct A
{
    size_t foo(){
        length!1 = 22; //expect to call a setter
        return length!0; //expect to call a getter
    }

     property size_t length(size_t n)()const{ return n; }

     property void length(size_t n)(size_t new_size){
        //set new size
    }
}

Instead of expected call issued the compiler spits out:
prop_bug.d(5): Error: template prop_bug.A.length matches more than one template
length(uint n)() and prop_bug.d(11):length(uint n)(size_t new_size)

prop_bug.d(6): Error: template prop_bug.A.length matches more than one template
declaration, prop_bug.d(9):length(uint n)() and prop_bug.d(11):length(uint
n)(size_t new_size)

Curiously if I (not using -property switch) change length!0 to length!0() it
compiles.

Tested on the dmd 2.061 from git-hub master
143e02d2b1fdb990cab3c6039c7459be3e90e142.

Putting both in a single template also works i.e. the following:

struct A
{
    size_t foo(){
        length!1 = 22;
        return length!0;
    }
    template length(size_t n)
    {
         property size_t length()const{ return n; }

         property void length(size_t new_size){
            //set new size
        }
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 07 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9121


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

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



10:32:08 PDT ---
Got fixed somehwere along the way.

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