https://issues.dlang.org/show_bug.cgi?id=5207

Nick Treleaven <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #10 from Nick Treleaven <[email protected]> ---
> isn't the idea of module constructors to not type check qualifiers because it 
> is considered that they are used to initialize data before the program is 
> actually run?

No, because the compiler does check the immutable qualifier for `s` below.

struct S
{
    int* p;
}
immutable S s;

shared static this()
{
    int* p = new int;
    s = S(p); // Error: cannot implicitly convert expression `S(p)` of type `S`
to `immutable(S)`
}

It would also be inconsistent with class constructor immutable field
initialization if immutable was completely ignored in a shared static
constructor - see issue 24449.

--

Reply via email to