mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Check while conditions after break or continue.
This commit is contained in:
1 parent
84bf437013
commit
5cce3afe4c
1 file changed
+23
-11
+23
-11
@@ -160,7 +160,21 @@ func (q *checker) bcheckStatement(n *a.Node) error {
|
|||||||
return q.bcheckIf(n.If())
|
return q.bcheckIf(n.If())
|
||||||
|
|
||||||
case a.KJump:
|
case a.KJump:
|
||||||
// No-op.
|
n := n.Jump()
|
||||||
|
skip := t.KeyPost
|
||||||
|
if n.Keyword().Key() == t.KeyBreak {
|
||||||
|
skip = t.KeyPre
|
||||||
|
}
|
||||||
|
for _, o := range n.JumpTarget().Asserts() {
|
||||||
|
if o.Assert().Keyword().Key() == skip {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := q.bcheckAssert(o.Assert()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
q.facts = q.facts[:0]
|
||||||
|
return nil
|
||||||
|
|
||||||
case a.KReturn:
|
case a.KReturn:
|
||||||
// TODO.
|
// TODO.
|
||||||
@@ -487,18 +501,16 @@ func (q *checker) bcheckWhile(n *a.While) error {
|
|||||||
}
|
}
|
||||||
// Check the pre and inv conditions on the implicit continue after the
|
// Check the pre and inv conditions on the implicit continue after the
|
||||||
// body.
|
// body.
|
||||||
for _, o := range n.Asserts() {
|
if !terminates(n.Body()) {
|
||||||
if o.Assert().Keyword().Key() == t.KeyPost {
|
for _, o := range n.Asserts() {
|
||||||
continue
|
if o.Assert().Keyword().Key() == t.KeyPost {
|
||||||
}
|
continue
|
||||||
if err := q.bcheckAssert(o.Assert()); err != nil {
|
}
|
||||||
return err
|
if err := q.bcheckAssert(o.Assert()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check the pre and inv conditions for each continue.
|
|
||||||
|
|
||||||
// TODO: check the inv and post conditions for each break.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assume the inv and post conditions.
|
// Assume the inv and post conditions.
|
||||||
|
|||||||
Reference in new issue
Block a user