D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5341 - alias this ignores invariant()
Summary: alias this ignores invariant()
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-10 05:17 UTC by Simen Kjaeraas
Modified: 2012-01-20 13:42 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Simen Kjaeraas 2010-12-10 05:17:58 UTC
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 Walter Bright 2012-01-20 13:42:39 UTC
Struct invariants are checked upon method entry and exit, they are not checked when fields are modified otherwise.