Stop using the enum as a manifest constant.

Jack Applegame japplegame at gmail.com
Sun Jun 6 14:05:54 UTC 2021


On Sunday, 6 June 2021 at 13:21:35 UTC, Mathias LANG wrote:
> It *might*, e.g. the following:
> ```D
> enum DEFAULT = foo();
> char[] foo () { return null; }
> void bar (char[] arg = DEFAULT);
> ```

Mutable enum??? WAT?
It's absolutely unacceptable.

```d
char[] foo() @safe { return "hello".dup; }
enum WAT = foo();
void main() @safe {
     WAT[0] = 'w';
     writeln(WAT);
}
```
```shell
Error: program killed by signal 11
```




More information about the Digitalmars-d mailing list