std.traits functions causing the compiler to crash
Eric
eric at makechip.com
Fri Jun 7 19:20:50 PDT 2013
O
> import std.traits: hasMember;
> interface Xidentity(V, K) if (!hasMember!(V, "x")) {
> }
> class Foo(K): Xidentity!(Foo!K, K) {
> K x;
> }
> void main() {
> new Foo!double;
> }
>
>
> I think it contains a loop at the level of types. In theory the
> compiler should catch them and give a nice error message.
>
> You probably want to use the template constraint syntax, as I
> have used.
Yes, the template constraint is much better. However, the
compiler
still crashes, even with the new code:
import std.traits: hasMember;
interface Identity(V, K) if (!hasMember!(V, "k")) {
}
class Foo(K): Identity!(Foo!K, K) {
K k;
}
void main() {
new Foo!double;
}
(dmd7) mrbig:~/tp/d_test2/dlib>dmd Test.d
Segmentation fault (core dumped)
> In D return is not a function, so don't use the ( ).
Yeah, I know. return returns an expression, and parenthesis
are legal expression syntax:)
-Eric
More information about the Digitalmars-d-learn
mailing list