Enum AA with classes not allowed anymore?

Daniel Kozak kozzi11 at gmail.com
Sun Oct 8 04:40:59 UTC 2017


Up to      2.062  : Failure with output:
-----
onlineapp.d(10): Error: cannot evaluate new Foo("0") at compile time
onlineapp.d(10): Error: cannot evaluate new Foo("1") at compile time
-----

2.063   to 2.072.2: Success with output: Hello D
Since      2.073.2: Failure with output: onlineapp.d(10): Error: variable
onlineapp.aa : Unable to initialize enum with class or pointer to struct.
Use static const variable instead.

https://run.dlang.io/is/mJqayC

On Sun, Oct 8, 2017 at 4:29 AM, bauss via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> I'm aware that the following has always been illegal:
>
> enum a = new Foo();
>
> However the following were used to work in older versions of DMD:
>
> enum aa = [0 : new Foo("0"), 1 : new Foo("1")];
>
> When did that change happen and what was the reason for the change? I were
> depending on AA's created like that to use them at compile-time.
>
> It happens to break my following project:
> https://github.com/bausshf/Diamond
>
> More specifically:
> https://github.com/bausshf/Diamond/blob/master/src/templates/parser.d#L13
>
> The change has happened somewhere between 2.072.2 and the current version.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20171008/fac72bb0/attachment.html>


More information about the Digitalmars-d mailing list