import std.stdio;
immutable int x;
shared static this()
{
x = 5; // OK, initialization not assignment
x.writeln(); // 5
x = 6; // should error
x++; // should error
assert(x == 7);
}
It should not be possible to assign immutable data after it is initialized in the shared static constructor. That would make those consistent with class constructors:
class C
{
immutable int x;
this()
{
x = 5;
x = 6; // error, x initialized multiple times
}
}