Warning on self assignment

Mike Franklin slavo5150 at yahoo.com
Wed Apr 25 02:23:04 UTC 2018


On Wednesday, 25 April 2018 at 01:08:46 UTC, Arun Chandrasekaran 
wrote:
> So I was telling my colleague that D would warn on self 
> assignment, but found that I was wrong.
>
> https://run.dlang.io/is/HLhtek
>
> ```
> module a;
>
> import std.stdio;
>
> void main() {
>     string a;
>     a = a;          // Can the compiler warn at this line that 
> there is no effect?
>     writeln(a);
>     return;
> }
> ```

Are people using self assignment of structs as a way of 
force-running the postblit?  Is there a valid use case for that?

Mike


More information about the Digitalmars-d-learn mailing list