www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21414] New: Spurious "non-constant expression" error with


          Issue ID: 21414
           Summary: Spurious "non-constant expression" error with
                    immutable constructors
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

//////////////////// test.d ///////////////////
struct State
    string s;

    immutable this(string s)
        this.s = s;

// Error: non-constant expression "b"[]
immutable rootState = new immutable State("b");

Works OK if you remove the constructor.

Works OK if you remove "immutable" (and make rootState __gshared).

Seems to be a regression, introduced in

Nov 21 2020