SOme fun with D compiler

wobbles via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 18 04:06:08 PDT 2016


On Tuesday, 18 October 2016 at 08:21:09 UTC, Daniel Kozak wrote:
> Try to compile this:
>
> import std.stdio;
>
> auto xxx(T)()
> {
>      return this;
> }
>
> struct S
> {
>     mixin xxx!(typeof(this));
>     alias xxx this;
> }
>
> void foo(S pos)
> {
>     writefln("(%.2f|%.2f)", pos.x, pos.y);
> }
>
> void main()
> {
> }
>
>
> Or this:
>
> import std.stdio;
>
> auto xxx(T)()
> if (is(T == struct))
> {
>      return this;
> }
>
> struct Vector2f
> {
>     mixin xxx!(typeof(this));
>     alias xxx this;
> }
>
> void foo(ref const Vector2f pos) {}
>
> void main()
> {
>     Vector2f v;
>     foo(v);
> }

Compiler bug?

Looks like it's constantly going in circles trying to figure out 
what the hell 'xxx' is :)
I cancelled compilation after a minute of 100% CPU usage so not 
sure if it will ever finish.


More information about the Digitalmars-d mailing list