Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dub test fails locally on Linux #382

Open
nordlow opened this issue Dec 6, 2021 · 1 comment
Open

dub test fails locally on Linux #382

nordlow opened this issue Dec 6, 2021 · 1 comment

Comments

@nordlow
Copy link
Contributor

nordlow commented Dec 6, 2021

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

?

@jmh530
Copy link
Contributor

jmh530 commented Dec 7, 2021

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));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants