Make the else-length-1 iterate tail explicit

This commit is contained in:
Nigel Tao committed 2018-05-11 10:22:24 +10:00
1 parent bfff18fd64
commit b65fdee306
6 files changed
+65 -92

No files matched your search

+3 -17
View File
@@ -299,10 +299,10 @@ func (q *checker) bcheckStatement(n *a.Node) error {
// execute-exactly-once block. We should have pre / inv / post
// conditions, a la bcheckWhile.
// Check the body.
{
variables := n.Variables()
for ; n != nil; n = n.ElseIterate() {
q.facts = q.facts[:0]
for _, o := range n.Variables() {
for _, o := range variables {
v := o.Var()
q.facts = append(q.facts, makeSliceLengthEqEq(v.Name(), v.XType(), n.Length()))
}
@@ -313,20 +313,6 @@ func (q *checker) bcheckStatement(n *a.Node) error {
}
}
// Check the tail.
{
q.facts = q.facts[:0]
for _, o := range n.Variables() {
v := o.Var()
q.facts = append(q.facts, makeSliceLengthEqEq(v.Name(), v.XType(), t.ID1))
}
for _, o := range n.Tail() {
if err := q.bcheckStatement(o); err != nil {
return err
}
}
}
q.facts = q.facts[:0]
return nil