Thread overview
[Issue 6905] New: ref acts as auto ref when return type is missing
Nov 07, 2011
Andrej Mitrovic
Feb 01, 2012
yebblies
Dec 24, 2012
Kenji Hara
Jan 09, 2013
Walter Bright
November 07, 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@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@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: -------
February 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6905


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com
           Platform|Other                       |All
         OS/Version|Windows                     |All


--- Comment #1 from yebblies <yebblies@gmail.com> 2012-02-02 00:30:36 EST ---
This happens because there is no actual storage class for auto ref, it just becomes auto ref when it is both auto and ref.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6905


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-12-24 00:48:46 PST ---
https://github.com/D-Programming-Language/dmd/pull/1401 https://github.com/D-Programming-Language/phobos/pull/1028

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6905



--- Comment #3 from github-bugzilla@puremagic.com 2012-12-24 01:30:27 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/2bbb33df2fa9f87ae73de6924031e1a854756ea1 Additional fix for issue 6905

For the inference of return value ref-ness, we should use 'auto ref' instead of 'ref' or 'const ref'

https://github.com/D-Programming-Language/phobos/commit/03a6e295fadd7c563a60069be0be3ada1c234666 Merge pull request #1028 from 9rnsr/fix6905

Additional fix for issue 6905

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6905



--- Comment #4 from github-bugzilla@puremagic.com 2013-01-08 20:09:35 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/251885197ac9470c65807f739ea49cdc983c5a3e fix Issue 6905 - ref acts as auto ref when return type is missing

https://github.com/D-Programming-Language/dmd/commit/f193abd3a39759f432197ba9f37e48518fb4499a Merge pull request #1401 from 9rnsr/fix6905

Issue 6905 - ref acts as auto ref when return type is missing

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6905


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


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