diff --git a/internal/shader/expr.go b/internal/shader/expr.go index f5b350248..d364ce377 100644 --- a/internal/shader/expr.go +++ b/internal/shader/expr.go @@ -155,16 +155,6 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar if lhst.Main != shaderir.None || rhst.Main != shaderir.None { t = shaderir.Type{Main: shaderir.Bool} } - case token.AND, token.OR, token.XOR, token.AND_NOT: - if lhs[0].Const.Kind() != gconstant.Int { - cs.addError(e.Pos(), fmt.Sprintf("operator %s not defined on %s (%s)", op, lhs[0].Const.String(), lhst.String())) - return nil, nil, nil, false - } - if rhs[0].Const.Kind() != gconstant.Int { - cs.addError(e.Pos(), fmt.Sprintf("operator %s not defined on %s (%s)", op, rhs[0].Const.String(), rhst.String())) - return nil, nil, nil, false - } - fallthrough default: v = gconstant.BinaryOp(lhs[0].Const, op, rhs[0].Const) switch { diff --git a/internal/shaderir/check.go b/internal/shaderir/check.go index dcf4825c7..fbb5a3c79 100644 --- a/internal/shaderir/check.go +++ b/internal/shaderir/check.go @@ -84,6 +84,11 @@ func AreValidTypesForBinaryOp(op Op, lhs, rhs *Expr, lhst, rhst Type) bool { if op == ModOp { return lhs.Const.Kind() == constant.Int && rhs.Const.Kind() == constant.Int } + + if op == And || op == Or || op == Xor { + return lhs.Const.Kind() == constant.Int && rhs.Const.Kind() == constant.Int + } + return true }