Bug 7685 – Cannot initialize const field if field initializer present

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-11T08:29:00Z
Last change time
2012-12-28T04:42:21Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-03-11T08:29:55Z
struct Foo { int val = int.init; this(inout(int) nval) inout { this.val = nval; } } test.d(18): Error: cannot modify const/immutable/inout expression this.val You can try with 'const', the results are the same. Also, the same thing happens if the field initializer is 'void'. So even if the above should be legal, I think it should be allowed if the field initializer is void.
Comment #1 by andrej.mitrovich — 2012-03-11T08:31:29Z
(In reply to comment #0) > So even if the above should be > legal, I think it should be allowed if the field initializer is void. Sorry, that should read 'even if the above should be illegal'.
Comment #2 by andrej.mitrovich — 2012-12-27T09:21:00Z
Seems to be fixed in 2.061.