November 13, 2020 Deprecation bug? | ||||
---|---|---|---|---|
| ||||
> struct A {
> void opAssign(int v) const {}
> }
>
> struct B {
> enum a = A();
> alias a this;
> }
>
> enum BB = B();
>
> void main() {
> BB = 10; // Deprecation: Cannot use alias this to partially initialize variable B() of type B. Use a.opAssign
> }
If you change `enum a = A()` to `immutable a = A()`, the deprecation disappears.
|
November 13, 2020 Re: Deprecation bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jack Applegame | On Friday, 13 November 2020 at 10:08:47 UTC, Jack Applegame wrote:
>> struct A {
>> void opAssign(int v) const {}
>> }
>>
>> struct B {
>> enum a = A();
>> alias a this;
>> }
>>
>> enum BB = B();
>>
>> void main() {
>> BB = 10; // Deprecation: Cannot use alias this to partially initialize variable B() of type B. Use a.opAssign
>> }
>
> If you change `enum a = A()` to `immutable a = A()`, the deprecation disappears.
But if you change `enum a = A()` to `static immutable a = A()`, the deprecation remains.
|
Copyright © 1999-2021 by the D Language Foundation