www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Alias this, templates and Algebraic - regression or expected behavior?

reply JN <666total wp.pl> writes:
This code:

import std.variant;

struct Vector(int T)
{
   float[T] elements;
}

struct Color
{
   Vector!4 vec;
   alias vec this;
}

Algebraic!(Color,Vector!4) foo;

void main()
{
   foo = Color();
}

according to run.dlang.io:

Up to      2.068.2: Success and no output
            2.069.2: Failure with output:
-----
/path/to/dmd/dmd2/linux/bin64/../../src/phobos/std/variant.d(578): Error:
static assert  "Cannot store a Color in a VariantN!(16LU, Color, Vector!4).
Valid types are (Vector!4, Vector!4)"
onlineapp.d(18):        instantiated from here: opAssign!(Color)
-----

            2.070.2: Failure with output: (same as above)
            2.071.2: Failure with output: (same as above)
            2.072.2: Failure with output: (same as above)
            2.073.2: Failure with output: (same as above)
2.074.1 to 2.075.1: Failure with output: (same as above)
2.076.1 to 2.078.1: Failure with output: (same as above)
2.079.1 to 2.080.1: Failure with output: (same as above)
2.081.2 to 2.083.1: Failure with output: (same as above)
Since      2.084.0: Failure with output: (same as above)


Is this expected? Should this code work?
Feb 24 2019
parent JN <666total wp.pl> writes:
On Sunday, 24 February 2019 at 18:33:29 UTC, JN wrote:
 This code:
Feb 24 2019