[Issue 18417] Make const and immutable postblit constructors illegal

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 14 15:28:56 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18417

--- Comment #8 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to RazvanN from comment #6)
> PR : https://github.com/dlang/dmd/pull/8032
> 
> The PR makes it illegal to declare a postblit const/immutable/shared,
> however,
> it is still possible to make a postblit const/immutable/shared by appending
> a qualifier to the struct:
> 
> immutable struct B
> {
>     this(this) {}
> }
> 
> There might be code in the wild which does this but never actually uses the
> postblit.

IMHO, it makes no sense whatsoever to allow for postblit constructor to be
const or immutable by marking the struct as const or immutable while making it
illegal to mark the postblit constructor const or immutable directly. Either,
it needs to be an error just like it is when marking the postblit constructor
directly, or it needs to not affect the postblit constructor. I believe that it
is currently the case that if immutable is used on a struct, that modifier is
ignored on constructors. If that is indeed the case, then the same rule should
apply to postblit constructors if marking a postblit constructor as const or
immutable is illegal.

--


More information about the Digitalmars-d-bugs mailing list