Should it compile?

Basile B. b2.temp at gmx.com
Sat Jun 6 11:58:06 UTC 2020


On Saturday, 6 June 2020 at 08:55:20 UTC, Jack Applegame wrote:
> Should it compile?
>
> ```d
> import std.algorithm.mutation;
>
> void main() {
>     const char a = void;
>     const char b ='b';
>     moveEmplace(b, a); // mutation.d: Error: cannot modify 
> const expression target
>     assert(a == 'b');
> }
> ```
> I think, it should.

maybe it shouldn't but then with another message, for example

     Error, cannot `void` initialize a `const` declaration.

since that makes very little sense, at least as a local variable. 
(as a member, this can be initialized in a constructor)



More information about the Digitalmars-d-learn mailing list