Skip to content

Commit 8b44641

Browse files
thk123danpoe
authored andcommitted
Adding extra information about invariant messages to CODING_STANDARD.md
1 parent ffe62af commit 8b44641

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

CODING_STANDARD.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,14 @@ Formatting is enforced using clang-format. For more information about this, see
191191
- The type is explicitly repeated on the RHS (e.g. a constructor call)
192192
- Adding the type will increase confusion (e.g. iterators, function pointers)
193193
- Avoid `assert`. If the condition is an actual invariant, use INVARIANT,
194-
PRECONDITION, POSTCONDITION, CHECK_RETURN, UNREACHABLE or DATA_INVARIANT. If
195-
there are possible reasons why it might fail, throw an exception.
194+
PRECONDITION, POSTCONDITION, CHECK_RETURN, UNREACHABLE or DATA_INVARIANT (also
195+
see the documentation of the macros in `src/util/invariant.h`). If there are
196+
possible reasons why it might fail, throw an exception.
197+
- Use "should" style statements for messages in invariants (e.g. "array
198+
should have a non-zero size") to make both the violation and the expected
199+
behavior clear. (As opposed to "no zero size arrays" where it isn't clear
200+
if the zero-size array is the problem, or the lack of it).
201+
- The statements should start with a lower case letter.
196202
- All raw pointers (such as those returned by `symbol_tablet::lookup`) are
197203
assumed to be non-owning, and should not be `delete`d. Raw pointers that
198204
point to heap-allocated memory should be private data members of an object

0 commit comments

Comments
 (0)