mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 00:47:56 +01:00
Require if and while conditions to be effect-free
This commit is contained in:
1 parent
5cca9471ec
commit
df19bcdb03
4 files changed
+16
-28
No files matched your search
@@ -94,6 +94,9 @@ func (q *checker) tcheckStatement(n *a.Node) error {
|
||||
case a.KIf:
|
||||
for n := n.AsIf(); n != nil; n = n.ElseIf() {
|
||||
cond := n.Condition()
|
||||
if cond.Effect() != 0 {
|
||||
return fmt.Errorf("check: internal error: if-condition is not effect-free")
|
||||
}
|
||||
if err := q.tcheckExpr(cond, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -224,6 +227,9 @@ func (q *checker) tcheckStatement(n *a.Node) error {
|
||||
case a.KWhile:
|
||||
n := n.AsWhile()
|
||||
cond := n.Condition()
|
||||
if cond.Effect() != 0 {
|
||||
return fmt.Errorf("check: internal error: while-condition is not effect-free")
|
||||
}
|
||||
if err := q.tcheckExpr(cond, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user