www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6503] New: std.typecons.scoped fails to instantiate for classes that inherit from interfaces

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

           Summary: std.typecons.scoped fails to instantiate for classes
                    that inherit from interfaces
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: debio264 gmail.com



---
code sample:
import std.typecons, std.stdio;

class A {
this() { writeln("A"); }
~this() { writeln("~A"); }
}

interface Bob {}

class ABob : A, Bob {
this() { writeln("ABob"); }
~this() { writeln("~ABob"); }
}

void main() { auto abob = scoped!ABob(); }

ABob is just a normal class, and creating an instance of it on the stack
shouldn't be a problem, but scoped fails to instantiate because
std.typecons.destroy fails to instantiate:


/usr/include/d2/4.6.0/std/typecons.d:2571: Error: template
std.typecons.destroy(T) if (is(T == class)) does not match any function
template declaration
/usr/include/d2/4.6.0/std/typecons.d:2571: Error: template
std.typecons.destroy(T) if (is(T == class)) cannot deduce template function
from argument types !()(A,Bob)
/usr/include/d2/4.6.0/std/typecons.d:2530: Error: template instance
std.typecons.destroy!(ABob) error instantiating
scopedtest.d:18:        instantiated from here: scoped!(ABob,)
scopedtest.d:18: Error: template instance std.typecons.scoped!(ABob,) error
instantiating


This error is interesting:
cannot deduce template function from argument types !()(A,Bob)

it looks like we're getting some sort of tuple of ABob's superclasses, trying
to instantiate destroy on it, and failing.

The correct behavior should be to special case classes that implement
interfaces so the interfaces are ignored when figuring out how to call
destructors.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6503


Andrew Wiley <debio264 gmail.com> changed:

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



---
Fix merged
https://github.com/D-Programming-Language/phobos/pull/199

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