immutable struct A
{
struct B
{
int x;
}
int x;
static int y;
}
void main()
{
A.y = 42; // works
A a;
// a.x = 42; // fails
A.B b;
b.x = 42; // works
}
-------------------------------------
Applying const/immutable qualifier to aggregate definition propagates it only to fields and methods of struct/class. static fields and nested definitions are left mutable which is extremely confusing and inconsistent with usual transitivity.
Comment #1 by robert.schadek — 2024-12-13T18:09:30Z