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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 12 06:20:14 UTC 2019


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

          Issue ID: 20443
           Summary: Case where code compiles depending on order of
                    declaration
           Product: D
           Version: D2
          Hardware: All
               URL: https://forum.dlang.org/post/wookkrecjzlvdyybyizf@foru
                    m.dlang.org
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

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


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

version(none)
class Class2 {
    Struct1!Class1 subscribers;
}

struct Struct1(T) {
    bool[T] items;
}

struct CallbackType1 {
    void delegate(Struct1!Class2) func;
}
alias CallbackType = SumType!CallbackType1;

class Class1 {
    CallbackType _callback;
    this(CallbackType callback) { // commenting out this ctor compiles OK
        _callback = callback;
    }
}

version(all)
class Class2 {
    Struct1!Class1 subscribers;
}

void main() {}
---

change the version(all) to version(none) and the version(none) no version(all)
and the code compiles.

run.dlang.io indicates a 2.066 regression

2.064   to 2.065.0: Success and no output
2.066.0 to 2.078.1: Failure with output: onlineapp.d(29): Error: struct
onlineapp.SumType!(CallbackType1).SumType is not copyable because it is
annotated with @disable
Since      2.079.1: Failure with output: onlineapp.d(29): Error: struct
`onlineapp.SumType!(CallbackType1).SumType` is not copyable because it is
annotated with `@disable`

--


More information about the Digitalmars-d-bugs mailing list