[Issue 6905] New: ref acts as auto ref when return type is missing

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 7 11:17:48 PST 2011


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

           Summary: ref acts as auto ref when return type is missing
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-11-07 11:17:13 PST ---
struct Foo
{
    int x;

    ref noReturnType()
    {
        return x;
    }
}

void main()
{
    auto foo = Foo();
    foo.noReturnType = 5;
    assert(foo.x == 5);
}

Should this be allowed? It doesn't make much sense, especially when you can
write code like this:

struct Foo
{
    ref noReturnType()
    {
        return 1;  // does an rvalue return
    }
}

void main()
{
    auto foo = Foo();
    auto x = foo.noReturnType();
}

This compiles and only confuses the reader.

-- 
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