Thread overview
[Issue 4501] New: Can't call templated properties as properties from within class
Jul 24, 2010
David Simcha
Dec 03, 2010
Stanislav Blinov
May 31, 2012
Kenji Hara
July 24, 2010
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


--- Comment #0 from David Simcha <dsimcha@yahoo.com> 2010-07-24 09:48:24 PDT ---
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: -------
December 03, 2010
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


--- Comment #1 from Stanislav Blinov <stanislav.blinov@gmail.com> 2010-12-02 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: -------
May 31, 2012
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


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-05-30 19:08:57 PDT ---
Works in 2.060head.

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