PR d/87824
d/dmd: Merge upstream dmd
fcc235e8e
Associative arrays are value types, which are not covariant with the
pointer type typeof(null).
Updates https://gcc.gnu.org/PR87824
Reviewed-on: https://github.com/dlang/dmd/pull/9435
From-SVN: r269561
-da26db81943952c7e35dab98650df589ec122485
+fcc235e8e25f7758266f7874edd5abefb9943e0b
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
}
else if (t1n->ty == t2n->ty && t1n->implicitConvTo(t2n))
goto Lcovariant;
- else if (t1n->ty == Tnull && t1n->implicitConvTo(t2n) &&
- t1n->size() == t2n->size())
- goto Lcovariant;
+ else if (t1n->ty == Tnull)
+ {
+ // NULL is covariant with any pointer type, but not with any
+ // dynamic arrays, associative arrays or delegates.
+ // https://issues.dlang.org/show_bug.cgi?id=8589
+ // https://issues.dlang.org/show_bug.cgi?id=19618
+ Type *t2bn = t2n->toBasetype();
+ if (t2bn->ty == Tnull || t2bn->ty == Tpointer || t2bn->ty == Tclass)
+ goto Lcovariant;
+ }
}
goto Lnotcovariant;
{
void f(T function() dg) { assert(!dg()); }
- static assert((T.sizeof == typeof(null).sizeof) == result);
+ static assert((is(typeof(null) function() : T function())) == result);
static assert(is(typeof( f(&retnull) )) == result);
static assert(is(typeof( f(()=>null) )) == result);
static if (result)
}
test!(true, int*)();
test!(true, Object)();
- test!(true, int[int])();
+ test!(false, int[int])();
test!(false, int[])();
test!(false, void delegate())();
}