mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 00:47:56 +01:00
Reject "x == 0" for pointer-typed x
This commit is contained in:
1 parent
fbec79df76
commit
fdf152f8b3
1 file changed
+14
-11
+14
-11
@@ -736,17 +736,6 @@ func (q *checker) tcheckExprBinaryOp(n *a.Expr, depth uint32) error {
|
|||||||
rTyp := rhs.MType()
|
rTyp := rhs.MType()
|
||||||
|
|
||||||
switch op {
|
switch op {
|
||||||
default:
|
|
||||||
if !lTyp.IsNumTypeOrIdeal() {
|
|
||||||
return fmt.Errorf("check: binary %q: %q, of type %q, does not have a numeric type",
|
|
||||||
op.AmbiguousForm().Str(q.tm), lhs.Str(q.tm), lTyp.Str(q.tm))
|
|
||||||
}
|
|
||||||
if !rTyp.IsNumTypeOrIdeal() {
|
|
||||||
return fmt.Errorf("check: binary %q: %q, of type %q, does not have a numeric type",
|
|
||||||
op.AmbiguousForm().Str(q.tm), rhs.Str(q.tm), rTyp.Str(q.tm))
|
|
||||||
}
|
|
||||||
case t.IDXBinaryNotEq, t.IDXBinaryEqEq:
|
|
||||||
// No-op.
|
|
||||||
case t.IDXBinaryAnd, t.IDXBinaryOr:
|
case t.IDXBinaryAnd, t.IDXBinaryOr:
|
||||||
if !lTyp.IsBool() {
|
if !lTyp.IsBool() {
|
||||||
return fmt.Errorf("check: binary %q: %q, of type %q, does not have a boolean type",
|
return fmt.Errorf("check: binary %q: %q, of type %q, does not have a boolean type",
|
||||||
@@ -756,6 +745,20 @@ func (q *checker) tcheckExprBinaryOp(n *a.Expr, depth uint32) error {
|
|||||||
return fmt.Errorf("check: binary %q: %q, of type %q, does not have a boolean type",
|
return fmt.Errorf("check: binary %q: %q, of type %q, does not have a boolean type",
|
||||||
op.AmbiguousForm().Str(q.tm), rhs.Str(q.tm), rTyp.Str(q.tm))
|
op.AmbiguousForm().Str(q.tm), rhs.Str(q.tm), rTyp.Str(q.tm))
|
||||||
}
|
}
|
||||||
|
case t.IDXBinaryNotEq, t.IDXBinaryEqEq:
|
||||||
|
if lTyp.Eq(typeExprStatus) && rTyp.Eq(typeExprStatus) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
if !lTyp.IsNumTypeOrIdeal() {
|
||||||
|
return fmt.Errorf("check: binary %q: %q, of type %q, does not have a numeric type",
|
||||||
|
op.AmbiguousForm().Str(q.tm), lhs.Str(q.tm), lTyp.Str(q.tm))
|
||||||
|
}
|
||||||
|
if !rTyp.IsNumTypeOrIdeal() {
|
||||||
|
return fmt.Errorf("check: binary %q: %q, of type %q, does not have a numeric type",
|
||||||
|
op.AmbiguousForm().Str(q.tm), rhs.Str(q.tm), rTyp.Str(q.tm))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch op {
|
switch op {
|
||||||
|
|||||||
Reference in new issue
Block a user