Bug 5516 – .init is broken for fields

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-02-01T17:43:00Z
Last change time
2015-06-09T01:31:21Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2011-02-01T17:43:35Z
struct Foo { int a; int b = 7; } void main() { Foo foo; assert(foo.b == 7); assert(foo.b.init == 7); // assertion failure } According to docs: .init produces a constant expression that is the default initializer. If applied to a type, it is the default initializer for that type. If applied to a variable or *field*, it is the default initializer for that variable or field.
Comment #1 by andrej.mitrovich — 2011-05-20T18:31:55Z
Invalid, code should be: Foo.init.b There's another report for the bug in docs so I'm closing this down.