mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 00:47:28 +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
@@ -656,6 +656,10 @@ func (p *parser) parseStatement1() (*a.Node, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if condition.Effect() != 0 {
|
||||
return nil, fmt.Errorf(`parse: while-condition %q is not effect-free at %s:%d`,
|
||||
condition.Str(p.tm), p.filename, p.line())
|
||||
}
|
||||
asserts, err := p.parseAsserts()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -709,6 +713,10 @@ func (p *parser) parseIf() (*a.If, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if condition.Effect() != 0 {
|
||||
return nil, fmt.Errorf(`parse: if-condition %q is not effect-free at %s:%d`,
|
||||
condition.Str(p.tm), p.filename, p.line())
|
||||
}
|
||||
bodyIfTrue, err := p.parseBlock()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user