Skip to content

Commit

Permalink
fix Issue 3578 - Impossible to run a struct invariant using assert(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jan 23, 2012
1 parent 5d98834 commit 8ed7c3d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions expression.dd
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,10 @@ $(GNAME AssertExpression):
$(B assert $(LPAREN)) $(GLINK AssignExpression) $(B ,) $(GLINK AssignExpression) $(B $(RPAREN))
)

$(P Asserts evaluate the $(I expression). If the result is false,
$(P Asserts evaluate the $(I AssignExpression).
If it evaluates to a non-null class reference, the class invariant is run.
Otherwise, if it evaluates to a non-null pointer to a struct, the struct invariant is run.
Otherwise, if the result is false,

This comment has been minimized.

Copy link
@yebblies

yebblies Jan 24, 2012

Member

With 796 fixed, this is no longer accurate.
After evaluated to a class or struct reference, an AssertError is thrown if the reference is null else the invariant is run.

an $(B AssertError) is thrown. If the result is true, then no
exception is thrown.
It is an error if the $(I expression) contains any side effects
Expand All @@ -1517,7 +1520,7 @@ $(GNAME AssertExpression):
assume that it is unreachable code.
)

$(P The second $(I Expression), if present, must be implicitly
$(P The second $(I AssignExpression), if present, must be implicitly
convertible to type $(V1 $(D char[]))$(V2 $(D const(char)[])).
It is evaluated if the
result is false, and the string result is appended to the
Expand Down

0 comments on commit 8ed7c3d

Please sign in to comment.