internal/shader: bug fix: a number literal must be represented as floats in some contexts

This commit is contained in:
Hajime Hoshi 2022-01-17 21:13:45 +09:00
parent 406b8a4a08
commit 0a537b7ad2

View File

@ -109,8 +109,11 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
return nil, false
}
case shaderir.Vec2, shaderir.Vec3, shaderir.Vec4, shaderir.Mat2, shaderir.Mat3, shaderir.Mat4:
if rts[0].Main == shaderir.Float || rhs[0].Const != nil {
// ok
if rts[0].Main == shaderir.Float {
// OK
} else if rhs[0].Const != nil && rhs[0].Const.Kind() == gconstant.Int {
rhs[0].Const = gconstant.ToFloat(rhs[0].Const)
rhs[0].ConstType = shaderir.ConstTypeFloat
} else {
cs.addError(stmt.Pos(), fmt.Sprintf("invalid operation: mismatched types %s and %s", lts[0].String(), rts[0].String()))
return nil, false