| |
| Posted by Walter Bright | PermalinkReply |
|
Walter Bright
| https://issues.dlang.org/show_bug.cgi?id=4995
Walter Bright <bugzilla@digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugzilla@digitalmars.com
--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Henning Pohl from comment #1)
> https://github.com/D-Programming-Language/dmd/pull/2155
This PR has a number of possible approaches. The difficulty is there are a number of attributes:
nothrow, @safe, pure, @nogc, const, immutable, shared
that may apply to invariants. Currently, const is applied. The PR applies pure (but does not check it) and @trusted, and adds code to silently convert thrown Exceptions to Errors inside of nothrow functions.
I'm uneasy with this. We also have backwards compatibility to be concerned about.
1. I can't think of a legitimate case where invariant can throw an Exception. Calling invariants or not should not be altering the normal behavior of a program. Hence, invariant should be implicitly nothrow.
2. Removal of checks for @system and purity is a hidden escape from the static guarantees of the language - seems wrong to me.
3. I think we can require the existence of a function body for invariants, and then do attribute inference on it.
--
|