www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11947] New: std.typecons.Proxy incorrectly handles variadic member templates

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11947

           Summary: std.typecons.Proxy incorrectly handles variadic member
                    templates
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: stanislav.blinov gmail.com


--- Comment #0 from Stanislav Blinov <stanislav.blinov gmail.com> 2014-01-19
01:41:15 PST ---
When forwarding member function calls, Proxy incorrectly handles cases when
member template is variadic:

import std.typecons : Proxy;

struct RealThing {
    void variadic(T...)(T args) {}
}

struct Impostor {
    private RealThing p;
    mixin Proxy!p;
}

void main()
{
    Impostor test;
    test.variadic();        // ok
    test.variadic("hello"); // error instantiating
}


Proposed solution:



// Original (std.typecons 3884):
// member template
template opDispatch(T...)
{
    auto ref opDispatch(this X, Args...)(auto ref Args args){ return
mixin("a."~name~"!T(args)"); }
}

// Change to (std.typecons 3884):
// member template
template opDispatch(T...)
{
    auto ref opDispatch(this X, Args...)(auto ref Args args)
    { 
        // T is empty, deduction is in effect
        static if (Args.length) { return
mixin("a."~name~"!"~Args.stringof~"(args)"); } 
        // T is explicitly specified        
        else                    { return mixin("a."~name~"!T(args)");          
      }
    }
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 19 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11947



--- Comment #1 from Stanislav Blinov <stanislav.blinov gmail.com> 2014-01-20
08:18:31 PST ---
Proxy's opCall() seems to exhibit similar issue, when using getter property as
proxy:

struct RealThing {
    void opCall(T...)(T args) {}
}

struct Impostor {
    private RealThing p;
    private  property RealThing* get() { return &p; }
    mixin Proxy!get;

    void opCall(T...)(T args) {}
}

void main() {
    Impostor imp;
    imp();        // ok
    imp("hello"); // error instantiating
}


Proposed solution (explicitly call opCall):

// Original (std.typecons 3817):
    auto ref opCall(this X, Args...)(auto ref Args args) { return a(args); }

// Change to (std.typecons 3817):
    auto ref opCall(this X, Args...)(auto ref Args args) { return
a.opCall(args); }

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11947



--- Comment #2 from Stanislav Blinov <stanislav.blinov gmail.com> 2014-01-20
22:48:49 PST ---
(In reply to comment #1)

 struct Impostor {
     private RealThing p;
     private  property RealThing* get() { return &p; }
     mixin Proxy!get;
 
     void opCall(T...)(T args) {}
 }

Uh, sloppy copy, sorry about that. Impostor should not have that opCall at all, only RealThing should. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 20 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11947


Stanislav Blinov <stanislav.blinov gmail.com> changed:

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


--- Comment #3 from Stanislav Blinov <stanislav.blinov gmail.com> 2014-02-08
14:53:39 PST ---
https://github.com/D-Programming-Language/phobos/pull/1914

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 08 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11947


Stanislav Blinov <stanislav.blinov gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow gmail.com


--- Comment #4 from Stanislav Blinov <stanislav.blinov gmail.com> 2014-03-04
09:10:12 PST ---
*** Issue 12297 has been marked as a duplicate of this issue. ***

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