[Issue 7182] Call const or immutable member functions from class invariant
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jun 26 07:51:19 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=7182
Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |dlang-bugzilla at thecybershad
| |ow.net
Resolution|--- |INVALID
--- Comment #2 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
(In reply to Infiltrator from comment #1)
> I think that the issue would instead be with the fact that public functions
> (f() in this case) call invariant() before and after they run, which would
> result in an infinite loop.
Pretty sure your explanation is correct.
Although one may argument in favor of making const methods not cause invariant
checks, that would mean that e.g. getters are no longer protected by
invariants, should something modify the object's state into an invalid one
directly (e.g. by writing to fields).
--
More information about the Digitalmars-d-bugs
mailing list