[Issue 6503] New: std.typecons.scoped fails to instantiate for classes that inherit from interfaces
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 16 00:40:15 PDT 2011
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 at puremagic.com
ReportedBy: debio264 at gmail.com
--- Comment #0 from Andrew Wiley <debio264 at gmail.com> 2011-08-16 00:40:11 PDT ---
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: -------
More information about the Digitalmars-d-bugs
mailing list