www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4501] New: Can't call templated properties as properties from within class

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

           Summary: Can't call templated properties as properties from
                    within class
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com



class Foo {
    int _num;

    int num()()  {
        return _num;
    }

    void doStuff() {
        int i = num;  // Broken
    }
}

void main() {
    auto foo = new Foo;
    auto n = foo.num;  // Works
}


Errors:
test9.d(8): Error: template num() has no value
test9.d(8): Error: cannot implicitly convert expression (num()) of type void to
int

If I comment out Foo.doStuff(), the line `auto n = bar.num;` works, apparently
becuase it's not inside the class.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 24 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4501


Stanislav Blinov <stanislav.blinov gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stanislav.blinov gmail.com
           Platform|Other                       |All
         OS/Version|Windows                     |All



16:27:16 PST ---
This seems related, though error manifests outside of class body:

class Bar
{
     property T num(T = int)() const // Note default type
    { 
        T result;
        //...
        return result;
    }
}

void main()
{
    auto bar = new Bar;
    auto n1 = bar.num!int; // Ok
    auto n2 = bar.num; // Error: Bar.num(T = int) has no value
    auto n3 = bar.num!float; // Ok
}

I don't know if it's worth separate issue report.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 02 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4501


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

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



Works in 2.060head.

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