mir-algorithm icon indicating copy to clipboard operation
mir-algorithm copied to clipboard

dub test fails locally on Linux

Open nordlow opened this issue 4 years ago • 1 comments

Why does dub test --build=unittest under mir-algorithm fail locally on Linux as

source/mir/math/stat.d(109,5): Error: static assert: `is(statType!(Foo, true) == Complex!float)` is false

?

nordlow avatar Dec 06 '21 23:12 nordlow

What version of DMD, mir-core, and mir-algorithm are are you using?

I would first make sure you are at least on the most recent versions of mir-core and mir-algorithm. There have been some changes recently to the layout of the complex types due to the deprecation of the built-in complex types.

I ran code below on run.dlang.io and it compiled without error. So I might need a bit more from your side to identify any issues.

/+dub.sdl:
dependency "mir-algorithm" version="*"
dependency "mir-core" version="*"
+/
import mir.complex;
import mir.internal.utility: isComplex, isFloatingPoint;
import std.traits: Unqual;

template statType(T, bool checkComplex = true)
{
    static if (isFloatingPoint!T) {
        import std.traits: Unqual;
        alias statType = Unqual!T;
    } else static if (is(T : double)) {
        alias statType = double;
    } else static if (checkComplex) {
        import mir.internal.utility: isComplex;
        static if (isComplex!T) {
            static if (__traits(getAliasThis, T).length == 1)
            {
                alias statType = .statType!(typeof(__traits(getMember, T, __traits(getAliasThis, T)[0]))); 
            }
            else
            {
                alias statType = Unqual!T;
            }
        } else {
            static assert(0, "statType: type " ~ T.stringof ~ " must be convertible to a complex floating point type");
        }
    } else {
        static assert(0, "statType: type " ~ T.stringof ~ " must be convertible to a floating point type");
    }
}

struct Foo {
    Complex!float x;
    alias x this;
}

void main()
{
    static assert(is(statType!Foo == Complex!float));
}

jmh530 avatar Dec 07 '21 00:12 jmh530