mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
internal/shader: bug fix: deduction checks for the %
operator were lacked
This commit is contained in:
parent
ab7c0c9137
commit
260f7e07df
@ -202,9 +202,11 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr, markLocalVariable
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
|
||||
// For `%`, both types must be deducible to integers.
|
||||
if op == shaderir.ModOp {
|
||||
// TODO: What about ivec?
|
||||
if lhst.Main != shaderir.Int || rhst.Main != shaderir.Int {
|
||||
if lhst.Main != shaderir.Int && (lhs[0].ConstType == shaderir.ConstTypeNone || !canTruncateToInteger(lhs[0].Const)) ||
|
||||
rhst.Main != shaderir.Int && (rhs[0].ConstType == shaderir.ConstTypeNone || !canTruncateToInteger(rhs[0].Const)) {
|
||||
var wrongType shaderir.Type
|
||||
if lhst.Main != shaderir.Int {
|
||||
wrongType = lhst
|
||||
|
@ -1283,6 +1283,24 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
|
||||
if _, err := ebiten.NewShader([]byte(`package main
|
||||
|
||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
a := int(2) % 0.5
|
||||
return vec4(a)
|
||||
}`)); err == nil {
|
||||
t.Errorf("error must be non-nil but was nil")
|
||||
}
|
||||
|
||||
if _, err := ebiten.NewShader([]byte(`package main
|
||||
|
||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
a := int(2) % 1.0
|
||||
return vec4(a)
|
||||
}`)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if _, err := ebiten.NewShader([]byte(`package main
|
||||
|
||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
a := 2.0
|
||||
b := 0.5
|
||||
|
Loading…
Reference in New Issue
Block a user