Thread overview
[Issue 10536] New: std.typecons.wrap doesn't work with a class that defines opCast
Jul 04, 2013
Kenji Hara
Jul 04, 2013
Kenji Hara
Sep 26, 2013
Andrej Mitrovic
July 04, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10536

           Summary: std.typecons.wrap doesn't work with a class that
                    defines opCast
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-04 00:47:34 PDT ---
std.typecons.wrap and unwrap internally uses cross-cast, but current implementation accidentally takes opCast member functions.

Code:
----
import std.typecons;

interface Interface { int foo(); }
class Pluggable {
    int foo() { return 1; }
    @disable void opCast(T, this X)();  // !
}
void main() {
    Interface i = new Pluggable().wrap!Interface;
    assert(i.foo() == 1);
}

Output:
----
std\typecons.d(2780): Error: function test.Pluggable.opCast!(inout(Object),
inout(Pluggable)).opCast is not callable because it is annotated with @disable
std\typecons.d(2780): Error: pure function
'std.typecons.wrap!(Interface).wrap!(Pluggable).Impl._wrap_getSource' cannot
call impure function 'test.Pluggable.opCast!(inout(Object),
inout(Pluggable)).opCast'
std\typecons.d(2780): Error: cannot implicitly convert expression
(this._wrap_source.opCast()) of type void to inout(Object)
test.d(16): Error: template instance
std.typecons.wrap!(Interface).wrap!(Pluggable) error instantiating
----

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


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

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


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-04 01:10:18 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1386

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



--- Comment #2 from github-bugzilla@puremagic.com 2013-09-26 05:55:07 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/830b6c1bd4cd465766c3d5b873c3c9838e16fc15
fix Issue 10536 - std.typecons.wrap doesn't work with a class that defines
opCast

https://github.com/D-Programming-Language/phobos/commit/36aa69b5ff06980dca4e31df046c122a50f75c22 Merge pull request #1386 from 9rnsr/fix_wrap

Issue 10536 & 10538 - std.typecons.wrap/unwrap bug fix and improvement

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


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich@gmail.com
         Resolution|                            |FIXED


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