diff --git a/internal/shader/expr.go b/internal/shader/expr.go index fb77bea05..c37371af5 100644 --- a/internal/shader/expr.go +++ b/internal/shader/expr.go @@ -91,8 +91,16 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr) ([]shaderir.Expr, }, []shaderir.Type{t}, stmts, true } + op, ok := shaderir.OpFromToken(e.Op) + if !ok { + cs.addError(e.Pos(), fmt.Sprintf("unexpected operator: %s", e.Op)) + return nil, nil, nil, false + } + var t shaderir.Type switch { + case op == shaderir.LessThanOp || op == shaderir.LessThanEqualOp || op == shaderir.GreaterThanOp || op == shaderir.GreaterThanEqualOp || op == shaderir.EqualOp || op == shaderir.NotEqualOp || op == shaderir.AndAnd || op == shaderir.OrOr: + t = shaderir.Type{Main: shaderir.Bool} case lhst.Equal(&rhst): t = lhst case lhst.Main == shaderir.Float || lhst.Main == shaderir.Int: @@ -129,12 +137,6 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr) ([]shaderir.Expr, return nil, nil, nil, false } - op, ok := shaderir.OpFromToken(e.Op) - if !ok { - cs.addError(e.Pos(), fmt.Sprintf("unexpected operator: %s", e.Op)) - return nil, nil, nil, false - } - return []shaderir.Expr{ { Type: shaderir.Binary,