http://d.puremagic.com/issues/show_bug.cgi?id=8683


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

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


--- Comment #2 from Maxim Fomin <ma...@maxim-fomin.ru> 2012-10-05 10:35:47 PDT 
---
(In reply to comment #0)
>
<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: -------

Reply via email to