[Issue 20443] Case where code compiles depending on order of declaration

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 13 16:45:10 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20443

--- Comment #5 from Daniel X <redapple82570 at gmail.com> ---
(In reply to Walter Bright from comment #3)
> Test cases are much better if they don't import libraries

Gotcha. Updated for convenience:

------
enum isCopyable(S) = is(typeof(
    { S foo = S.init; S copy = foo; }
));

struct SumType(T) {
    static if (!isCopyable!T)
        @disable this(this);
}

struct CallbackType1 {
    bool[Class1] func;   // changing to Class1[] compiles OK
}

// moving Class1 above CallbackType1 compiles OK
class Class1 {
    SumType!CallbackType1 _callback;
    this(SumType!CallbackType1 callback) { // commenting out this ctor compiles
OK
        _callback = callback;
    }
}

--


More information about the Digitalmars-d-bugs mailing list