Thread overview
super simple code, super slow to compile
Mar 31
Basile B.
Mar 31
Basile B.
Mar 31
Basile B.
March 31
I've found this yesterday while exploring issues:

---
import std.typecons: Typedef;
alias Matrix = double[260][260];
alias Foo = Typedef!Matrix;
void main() {}
---

It's super slow to compile, here 2 seconds. Change the dimension of the 2nd static array type to 10 and it's more acceptable.

At first glance I'd say that the compiler is doing something stupid.
March 31
On Sunday, 31 March 2019 at 05:37:25 UTC, Basile B. wrote:
> I've found this yesterday while exploring issues:
>
> ---
> import std.typecons: Typedef;
> alias Matrix = double[260][260];
> alias Foo = Typedef!Matrix;
> void main() {}
> ---
>
> It's super slow to compile, here 2 seconds. Change the dimension of the 2nd static array type to 10 and it's more acceptable.
>
> At first glance I'd say that the compiler is doing something stupid.

Well it's not dmd that does something stupid, it's phobos.
Typedef default initializer is stored in the type signature.
 init as template param should be void and in this case void would be used to set the payload to the actual init. When people want real void init they can do them the classic way anyway

alias M = Typedef!Matrix; // Typedef!(Matrix, void, null);
M m = void;

gotta make a PR lol.

March 31
On Sunday, 31 March 2019 at 07:31:57 UTC, Basile B. wrote:
> On Sunday, 31 March 2019 at 05:37:25 UTC, Basile B. wrote:
>> [...]
>
> Well it's not dmd that does something stupid, it's phobos.
> Typedef default initializer is stored in the type signature.
>  init as template param should be void and in this case void would be used to set the payload to the actual init. When people want real void init they can do them the classic way anyway
>
> alias M = Typedef!Matrix; // Typedef!(Matrix, void, null);
> M m = void;
>
> gotta make a PR lol.

Mmmh CTFE doesn't accept uninitialized variables...
To solve the issue the template parameter must be dropped entirely.