[Issue 5531] New: Erratic type deduction with pointers and type modifiers
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 6 07:40:35 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5531
Summary: Erratic type deduction with pointers and type
modifiers
Product: D
Version: D2
Platform: Other
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: michel.fortin at michelf.com
--- Comment #0 from Michel Fortin <michel.fortin at michelf.com> 2011-02-06 10:38:12 EST ---
Type deduction should match types which are a specialization of the given base
type, but this doesn't work when type modifiers are involved. Here is a list of
test cases which have been rigged to pass with the current compiler, but each
test with a FIXME on should be considered wrong.
template ap(T : int*) {
enum ap = 1;
}
static assert(ap!(int*));
static assert(ap!(const(int*))); // FIXME: should not match
static assert(ap!(const(int)*)); // FIXME: should not match
static assert(ap!(immutable(int*))); // FIXME: should not match
static assert(ap!(immutable(int)*)); // FIXME: should not match
static assert(ap!(shared(int*))); // FIXME: should not match
static assert(ap!(shared(int)*)); // FIXME: should not match
template bp(T : const(int*)) {
enum bp = 1;
}
static assert(bp!(int*));
static assert(bp!(const(int*)));
static assert(bp!(const(int)*));
static assert(bp!(immutable(int*)));
static assert(bp!(immutable(int)*));
static assert(bp!(shared(int*))); // FIXME: should not match
static assert(bp!(shared(int)*)); // FIXME: should not match
template cp(T : const(int)*) {
enum cp = 1;
}
static assert(cp!(int*));
static assert(cp!(const(int*))); // FIXME: should not match (const ptr)
static assert(cp!(const(int)*));
static assert(cp!(immutable(int*))); // FIXME: should not match (immutable ptr)
static assert(cp!(immutable(int)*));
static assert(cp!(shared(int*))); // FIXME: should not match
static assert(cp!(shared(int)*)); // FIXME: should not match
template dp(T : U*, U) {
alias U dp;
}
static assert(is(dp!(int*) == int));
static assert(is(dp!(const(int*)) == const(int))); // FIXME: should not match
(const ptr)
static assert(is(dp!(const(int)*) == const(int)));
static assert(is(dp!(immutable(int*)) == immutable(int))); // FIXME: should not
match (immutable ptr)
static assert(is(dp!(immutable(int)*) == immutable(int)));
static assert(is(dp!(shared(int*)) == shared(int))); // FIXME: should not match
(shared ptr)
static assert(is(dp!(shared(int)*) == shared(int)));
template ep(T : const(U*), U) {
alias U ep;
}
static assert(is(ep!(int*) == int));
static assert(is(ep!(const(int*)) == int));
static assert(is(ep!(const(int)*) == int));
static assert(is(ep!(immutable(int*)) == int));
static assert(is(ep!(immutable(int)*) == int));
static assert(!is(ep!(shared(int*)))); // no match
static assert(!is(ep!(shared(int)*))); // no match
template fp(T : const(U)*, U) {
alias U fp;
}
static assert(is(fp!(int*) == int));
static assert(is(fp!(const(int*)) == int)); // FIXME: should not match (const
ptr)
static assert(is(fp!(const(int)*) == int));
static assert(is(fp!(immutable(int*)) == int)); // FIXME: should not match
(immutable ref)
static assert(is(fp!(immutable(int)*) == int));
static assert(!is(fp!(shared(int*)))); // no match
static assert(!is(fp!(shared(int)*))); // no match
--
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