Thread overview
[Issue 6404] New: Cannot check ref-ness of auto ref parameter in template constraint
Jul 30, 2011
Kenji Hara
Jul 30, 2011
Walter Bright
Jul 31, 2011
Kenji Hara
Jul 31, 2011
Kenji Hara
Oct 03, 2011
Walter Bright
Feb 10, 2012
dawg@dawgfoto.de
July 30, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6404

           Summary: Cannot check ref-ness of auto ref parameter in
                    template constraint
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2011-07-29 22:20:45 PDT ---
Cannot compile following code:

// receive only rvalue
void rvalue(T)(auto ref T x) if (!__traits(isRef, x)) {}

// receive only lvalue
void lvalue(T)(auto ref T x) if ( __traits(isRef, x)) {}

void main()
{
    int n;

    static assert(!__traits(compiles, rvalue(n)));
    static assert( __traits(compiles, rvalue(0)));

    static assert( __traits(compiles, lvalue(n)));
    static assert(!__traits(compiles, lvalue(0)));
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 30, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6404


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2011-07-30 13:08:23 PDT ---
https://github.com/D-Programming-Language/dmd/commit/407cd0fa8bfe7443302bbf460d56a1e1847c5c01

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 31, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6404


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-07-31 02:47:58 PDT ---
Sorry my patch is incomplete, because it does not support auto ref tuple parameter.

void rvalueVargs(T...)(auto ref T x) if (!__traits(isRef, x[0])) {}
void lvalueVargs(T...)(auto ref T x) if ( __traits(isRef, x[0])) {}
void test6404()
{
    int n;

    static assert(!__traits(compiles, rvalueVargs(n)));
    static assert( __traits(compiles, rvalueVargs(0)));

    static assert( __traits(compiles, lvalueVargs(n)));
    static assert(!__traits(compiles, lvalueVargs(0)));
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 31, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6404


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2011-07-31 03:21:54 PDT ---
Retry to fix it. https://github.com/D-Programming-Language/dmd/pull/285

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 03, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6404


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2011-10-02 18:18:53 PDT ---
https://github.com/D-Programming-Language/dmd/commit/91debf464f8b6c49a0d522d10fce285ad1a5f9e7

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


dawg@dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dawg@dawgfoto.de


--- Comment #5 from dawg@dawgfoto.de 2012-02-10 06:10:29 PST ---
I think it would be neat to extend this to IsExpressions.
void foo()(auto ref int val) if (is(typeof(val) == ref))

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