Bug 5341 – alias this ignores invariant()

Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-12-10T05:17:00Z
Last change time
2012-01-20T13:42:39Z
Assigned to
nobody
Creator
simen.kjaras

Comments

Comment #0 by simen.kjaras — 2010-12-10T05:17:58Z
struct foo { int data; alias data this; invariant() { assert( data == 0 ); } } void bar( ) { foo f; f = 4; // No assert } Not sure if this will ever be fixed, or even is supposed to, but I feel it is worth adding here.
Comment #1 by bugzilla — 2012-01-20T13:42:39Z
Struct invariants are checked upon method entry and exit, they are not checked when fields are modified otherwise.