www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10886] New: Typeof in templates works incorrectly

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

           Summary: Typeof in templates works incorrectly
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: temtaime gmail.com



struct A {
    pure auto foo()  property { return 0; }
}

struct B {
    void bar(T)() {
        alias B = typeof(T.foo);
    }
}

void main() {
    B b;
    b.bar!A();
}

Output:
Error: this for foo needs to be type A not type B
Error: template instance hello.B.bar!(A) error instantiating

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




Reduced declaration of foo:
int foo()  property { return 0; }

Problem goes away if  property is removed.

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



14:41:46 PDT ---
It's unrelated to templates:

-----
struct A
{
     property int foo() { return 0; }
    int bar() { return 0; }
}

struct B
{
    void bar()
    {
        alias f = typeof(A.foo);  // NG
        alias b = typeof(A.bar);  // ok
    }
}

void main()
{
}
-----

AFAIK there are/will be changes to how typeof() works with properties as well.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 24 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10886




Oh, yes, sorry. It's too late where i am, so my example is ugly.

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