Allow "assert foo", not just "assert foo < bar".

This commit is contained in:
Nigel Tao committed 2017-11-09 10:53:37 +11:00
1 parent e2ce9f1b1d
commit 3bdd515e47
3 files changed
+13 -5

No files matched your search

+1 -1
View File
@@ -2017,7 +2017,7 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
b_rend_src = b_rptr_src + len;
}
if ((a_dst.private_impl.mark != NULL) != true) {
if (!(a_dst.private_impl.mark != NULL)) {
status = PUFFS_FLATE__ERROR_BAD_ARGUMENT;
goto exit;
}
+8
View File
@@ -310,8 +310,15 @@ func (q *checker) bcheckStatement(n *a.Node) error {
}
func (q *checker) bcheckAssert(n *a.Assert) error {
// TODO: check, here or elsewhere, that the condition is pure.
condition := n.Condition()
for _, x := range q.facts {
if x.Eq(condition) {
return nil
}
}
err := errFailed
if cv := condition.ConstValue(); cv != nil {
if cv.Cmp(one) == 0 {
err = nil
@@ -325,6 +332,7 @@ func (q *checker) bcheckAssert(n *a.Assert) error {
} else if condition.ID0().IsBinaryOp() && condition.ID0().Key() != t.KeyAs {
err = q.proveBinaryOp(condition.ID0().Key(), condition.LHS().Expr(), condition.RHS().Expr())
}
if err != nil {
if err == errFailed {
return fmt.Errorf("check: cannot prove %q", condition.String(q.tm))
+4 -4
View File
@@ -21,7 +21,7 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
// correctness and performance.
// TODO: make this a func pre-condition.
if in.dst.is_marked() != true { // TODO: if not in.dst.is_marked() {
if not in.dst.is_marked() {
return error "bad argument"
}
@@ -65,7 +65,7 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
// code requires up to 2 + 2 + 2 == 6 bytes, and there are two codes (one
// from H-L and one from H-D). Therefore, we check for at least 12 bytes.
while:loop(in.dst.available() >= 258) and (in.src.available() >= 12),
inv in.dst.is_marked() == true, // TODO: remove the redundant "== true".
inv in.dst.is_marked(),
{
// Ensure that we have at least 15 bits of input.
if n_bits < 15 {
@@ -268,7 +268,7 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
// its presence minimizes the diff between decode_huffman_fast and
// decode_huffman_slow.
while true,
inv in.dst.is_marked() == true,
inv in.dst.is_marked(),
{
// Copy from this.history.
if (distance as u64) > in.dst.since_mark().length() {
@@ -298,7 +298,7 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
// "etc", but its presence minimizes the diff between
// decode_huffman_fast and decode_huffman_slow.
while true,
inv in.dst.is_marked() == true,
inv in.dst.is_marked(),
{
n_copied = in.dst.copy_from_slice32(s:this.history[hdist:], length:hlen)
if hlen <= n_copied {