On Wed, Jul 30, 2025 at 10:54:15AM -0600, Jonathan M Davis via 
Digitalmars-d-learn wrote:
[...]
> immutable int[] i;
> 
> shared static this()
> {
>     immutable(int)[] temp;
>     temp ~= foo();
>     temp ~= bar();
>     i = temp;
> }
> 
> But even the shared static constructor isn't allowed to mutate the
> value of i. It's allowed to initialize it exactly once.
[...]

In that case, there is a bug:

```
static immutable int[] data;
shared static this() {
        data = [ 1 ];
        data = [ 2 ];   // should not compile, but currently does
}
```


T

-- 
Why did the chicken cross the Möbius strip?  To get to the same side!

Reply via email to