Re: needing to change the order of things at module level = compiler bug, right?
On Thursday, 12 December 2019 at 06:23:31 UTC, Basile B. wrote: Still worth opening an issue. https://issues.dlang.org/show_bug.cgi?id=20443 Thanks, Basile. I've added additional information from the github thread where the sumtype author helpfully looked into the problem.
Re: needing to change the order of things at module level = compiler bug, right?
On Sunday, 8 December 2019 at 18:13:59 UTC, DanielG wrote: On Sunday, 8 December 2019 at 18:01:03 UTC, Steven Schveighoffer wrote: Yes, if it can compile when you move things around, and the result is *correct* (very important characteristic) Indeed, everything's working as intended when rearranged. Thanks! Still worth opening an issue. https://issues.dlang.org/show_bug.cgi?id=20443
Re: needing to change the order of things at module level = compiler bug, right?
On Sunday, 8 December 2019 at 18:01:03 UTC, Steven Schveighoffer wrote: Yes, if it can compile when you move things around, and the result is *correct* (very important characteristic) Indeed, everything's working as intended when rearranged. Thanks!
Re: needing to change the order of things at module level = compiler bug, right?
On 12/8/19 11:43 AM, DanielG wrote: I dustmite'd down my problem code, and it seems just changing the order of declarations makes the error go away. Specifically, moving a class declaration from the bottom of the file, to the top, allows it to compile. I also commented on two other things that can be changed to make it work - neither seemingly related to the error at hand. Yes, if it can compile when you move things around, and the result is *correct* (very important characteristic), then it's definitely a bug. There should be no ordering requirements for module-level code. -Steve
needing to change the order of things at module level = compiler bug, right?
I dustmite'd down my problem code, and it seems just changing the order of declarations makes the error go away. Specifically, moving a class declaration from the bottom of the file, to the top, allows it to compile. I also commented on two other things that can be changed to make it work - neither seemingly related to the error at hand. Just double-checking before I file a bug for this: -- import sumtype; // DMD 2.089.0-dirty (also v2.087.1) // app.d(18,13): Error: struct sumtype.SumType!(CallbackType1).SumType is not copyable because it is annotated with @disable struct Struct1(T) { bool[T] items; } struct CallbackType1 { void delegate(Struct1!Class2) func; // changing arg to Class2[] compiles OK } alias CallbackType = SumType!CallbackType1; class Class1 { CallbackType _callback; this(CallbackType callback) { // commenting out this ctor compiles OK _callback = callback; } } // moving Class2 to the top of the file compiles OK class Class2 { Struct1!Class1 subscribers; } void main() {}