Why does this not compile?
Steven Schveighoffer
schveiguy at yahoo.com
Tue Mar 6 12:00:43 UTC 2018
On 3/6/18 6:21 AM, Simen Kjærås wrote:
> On Tuesday, 6 March 2018 at 10:03:54 UTC, Shachar Shemesh wrote:
>> void main() {
>> struct S {
>> uint value;
>>
>> ~this() {
>> }
>> }
>>
>> const S a = S(12);
>> S b = a;
>> }
>>
>> test.d(10): Error: cannot implicitly convert expression a of type
>> const(S) to S
>
> Looks like a bug to me - please file one in bugzilla.
Nope. It's not a bug. S contains a pointer, namely the context pointer
for main.
https://dlang.org/spec/struct.html#nested
Try this:
void main() {
static struct S {
uint value;
~this() {}
}
... // rest of your code
}
-Steve
More information about the Digitalmars-d
mailing list