[Issue 3231] Function declared to return a type with its same name doesn't compile

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 8 16:42:02 PDT 2009


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





--- Comment #12 from Tim M <tim.matthews7 at gmail.com>  2009-08-08 16:42:01 PDT ---
Adding the dot is so trivial and takes no time at all. I do believe that this
is indeed a bug anyway explanation of such:

This code will not compile:

class A
{
    void func();
    func getFunc()
    {
        return null;
    }
}
void main()
{
}


You cannot return a 'func' as it is not a type. 'func' is actually an instance
of 'delegate' so it should have been declared as that.


class A
{
    void func();
    void getFunc()
    {
        new func();
    }
}
void main()
{
}

Here 'getFunc' is declared as void but it doesn't compile either because this
time I am trying to new a 'func' which causes a compile error again because
'func' is not a type but an instance of delegate.

Whenever a peice of D code contains 2 identifiers next to each other like so:

AB XY

It can only mean either XY is an instance (whether that be value, ref, of
function returning) and AB is a type. Likewise I can't 'new' everything either.

The bug is simply that dmdfe wasn't attempting to find a type or instance with
the particular name but it was satisfied with the first symbol it found.

If this indeed hard to fixup now (and I would rather Walter focus on more
important issues) then adding a couple of dots is something I wouldn't mind to
do either (it would require a few bytes of code)

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


More information about the Digitalmars-d-bugs mailing list