Bug 19464 – typeof immutable fields order dependent

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-12-04T13:56:21Z
Last change time
2018-12-12T09:32:22Z
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2018-12-04T13:56:21Z
When declaring an immutable field using typeof() on another immutable field, the field in typeof() has to be declared above or the new one won't be immutable. Code: ``` typeof(a0) b0 = 3; immutable int a0 = 4; pragma(msg, typeof(b0)); immutable int a1 = 4; typeof(a1) b1 = 3; pragma(msg, typeof(b1)); ``` Expected: immutable(int) immutable(int) Actual: int immutable(int)
Comment #1 by simen.kjaras — 2018-12-04T14:07:15Z
This only occurs for basic types - structs, classes, arrays, assoc arrays, pointers, aliases, etc, don't exhibit this behavior.
Comment #2 by razvan.nitu1305 — 2018-12-11T14:48:54Z
Comment #3 by github-bugzilla — 2018-12-12T09:32:21Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/b5f54880fea5a9a5bd1cbdb6767a2e34ef2b8761 Fix Issue 19464 - typeof immutable fields order dependent https://github.com/dlang/dmd/commit/20d13c614574ad08aab81cfb41d605606dcc43fd Merge pull request #9069 from RazvanN7/Issue_19477 Fix Issue 19464 - typeof immutable fields order dependent