mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
Check the if condition has boolean type.
This commit is contained in:
1 parent
da9612667e
commit
57598bee41
1 file changed
+6
-2
+6
-2
@@ -91,10 +91,14 @@ func (c *typeChecker) checkStatement(n *a.Node) error {
|
|||||||
|
|
||||||
case a.KIf:
|
case a.KIf:
|
||||||
for o := n.If(); o != nil; o = o.ElseIf() {
|
for o := n.If(); o != nil; o = o.ElseIf() {
|
||||||
if err := c.checkExpr(o.Condition()); err != nil {
|
cond := o.Condition()
|
||||||
|
if err := c.checkExpr(cond); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// TODO: check o.Condition() has type bool.
|
if !cond.MType().Eq(TypeExprBoolean) {
|
||||||
|
return fmt.Errorf("check: if condition %q, of type %q, does not have a boolean type",
|
||||||
|
cond.String(c.idMap), cond.MType().String(c.idMap))
|
||||||
|
}
|
||||||
for _, m := range o.BodyIfTrue() {
|
for _, m := range o.BodyIfTrue() {
|
||||||
if err := c.checkStatement(m); err != nil {
|
if err := c.checkStatement(m); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in new issue
Block a user