mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Check the for-loop condition has boolean type.
This commit is contained in:
1 parent
c3c600627b
commit
87dcd9ed55
2 files changed
+7
-1
No files matched your search
@@ -59,6 +59,9 @@ func TestCheck(t *testing.T) {
|
||||
b = not true
|
||||
|
||||
y = x as i32
|
||||
|
||||
for x > 0 {
|
||||
}
|
||||
}
|
||||
`) + "\n"
|
||||
|
||||
|
||||
+4
-1
@@ -89,7 +89,10 @@ func (c *typeChecker) checkStatement(n *a.Node) error {
|
||||
if err := c.checkExpr(cond); err != nil {
|
||||
return err
|
||||
}
|
||||
// TODO: check cond has type bool.
|
||||
if !cond.MType().Eq(TypeExprBoolean) {
|
||||
return fmt.Errorf("check: for-loop condition %q, of type %q, does not have a boolean type",
|
||||
cond.String(c.idMap), cond.MType().String(c.idMap))
|
||||
}
|
||||
}
|
||||
for _, m := range o.Body() {
|
||||
if err := c.checkStatement(m); err != nil {
|
||||
|
||||
Reference in new issue
Block a user