www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8683] New: bad type resolution for template property functions

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

           Summary: bad type resolution for template property functions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ellery-newcomer utulsa.edu



21:00:30 PDT ---
code:

 property int Foo()() {
    return 1;
}

 property int Goo() {
    return 1;
}

pragma(msg, typeof(Foo));
pragma(msg, typeof(Goo));

void main() {
    import std.stdio;
    writeln(Foo);
    writeln(Goo);
}


should spit out

int
int

does spit out

void
int

when compiled. 

prints 

1
1

when ran.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 17 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8683


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

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



18:59:29 PDT ---
Maybe typeof(Foo!()) is required here?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8683


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru



---


<skip>

It may or may not be a bug depending on what spec says and it says little about
it. Dlang.org template page says that semantic analysis is done after template
instantiation and in your case it is not instantiated. On the one hand, it is
obvious that return type does not vary and is always int. On the other hand,
dmd is not obligated to do so until full template instantiation. 

TDPL p.139-140 says that D uses heterogeneous translation which means that int
Foo()() is not a compiled function like int Goo(). At p.236 it additionally
says that Foo()() is not a type, it's a means to create a type. This means that
asking a typeof from something that is not a type is problematic.

The key point here is whether typeof(Foo) should instantiate type or not for
templates like Foo. If it should instantiate, then it should correctly parse
return type. If not (and it seems that typeof of templates which cannot be
easily instantiated as Foo), than typeof should return some invalid type (like
void) or just issue error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 05 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8683




---
This code demonstrates the issue http://dpaste.dzfl.pl/9f2cc42f

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 05 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8683




17:51:37 PDT ---

 Maybe typeof(Foo!()) is required here?
That does work, but I don't see why pragma(msg, typeof(Foo)); should fail while writeln(Foo); succeeds. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 07 2012