[Issue 20076] New: [2.087.0] structs won't copy when using alias this and being assigned a const instance of said struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 23 16:21:50 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20076
Issue ID: 20076
Summary: [2.087.0] structs won't copy when using alias this and
being assigned a const instance of said struct
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: blocker
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: gooberman at gmail.com
Created attachment 1756
--> https://issues.dlang.org/attachment.cgi?id=1756&action=edit
Code example. The last two lines should be functionally identical to the prior
two lines. Currently they error; and as long as alias this resolves they won't
give the correct output...
Assigning a T to a const( T ) results in a proper struct copy.
Assigning a const( T ) to a T results in alias this resolving on const( T ) and
tries to construct T with it.
This is quite whack, and resolving alias this in that manner breaks a lot of
assumptions in my code about how copying structs is meant to work.
Haven't been able to work around it with opAssign yet.
--
More information about the Digitalmars-d-bugs
mailing list