Bug 21414 – Spurious "non-constant expression" error with immutable constructors
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-11-22T02:42:26Z
Last change time
2021-12-14T10:34:14Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Vladimir Panteleev
Comments
Comment #0 by dlang-bugzilla — 2020-11-22T02:42:26Z
//////////////////// 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
https://github.com/dlang/dmd/pull/4719
Comment #1 by dlang-bot — 2021-11-25T11:28:25Z
@RazvanN7 created dlang/dmd pull request #13358 "Fix Issue 21414 - Spurious non-constant expression error with immutable constructors" fixing this issue:
- Fix Issue 21414 - Spurious non-constant expression error with immutable constructors
https://github.com/dlang/dmd/pull/13358
Comment #2 by dlang-bot — 2021-11-26T07:09:55Z
dlang/dmd pull request #13358 "Fix Issue 21414 - Spurious `non-constant` expression error with immutable constructors" was merged into stable:
- 3e1dd9762af33aa2f5be71a1c3cee1ac0602a5a3 by RazvanN7:
Fix Issue 21414 - Spurious non-constant expression error with immutable constructors
https://github.com/dlang/dmd/pull/13358
Comment #3 by dlang-bot — 2021-12-14T10:34:14Z
dlang/dmd pull request #13421 "merge stable" was merged into master:
- 473f409206cb98c753e9baa6ec55c3bcb127c7d2 by Razvan Nitu:
Fix Issue 21414 - Spurious non-constant expression error with immutable constructors (#13358)
https://github.com/dlang/dmd/pull/13421