mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
internal/shader: bug fix: xor-assignment operator didn't work correctly
Closes #3140
This commit is contained in:
parent
366f4899a2
commit
74f812dd33
@ -117,11 +117,12 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
|
||||
if op == shaderir.And || op == shaderir.Or || op == shaderir.Xor || op == shaderir.LeftShift || op == shaderir.RightShift {
|
||||
if lts[0].Main != shaderir.Int && !lts[0].IsIntVector() {
|
||||
cs.addError(stmt.Pos(), fmt.Sprintf("invalid operation: operator %s not defined on %s", stmt.Tok, lts[0].String()))
|
||||
return nil, false
|
||||
}
|
||||
if rts[0].Main != shaderir.Int && !rts[0].IsIntVector() {
|
||||
cs.addError(stmt.Pos(), fmt.Sprintf("invalid operation: operator %s not defined on %s", stmt.Tok, rts[0].String()))
|
||||
return nil, false
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
if lts[0].Main == shaderir.Int && rhs[0].Const != nil {
|
||||
if !cs.forceToInt(stmt, &rhs[0]) {
|
||||
|
6
internal/shader/testdata/xorassign.expected.vs
vendored
Normal file
6
internal/shader/testdata/xorassign.expected.vs
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
int F0(in int l0);
|
||||
|
||||
int F0(in int l0) {
|
||||
l0 = (l0) ^ (l0);
|
||||
return l0;
|
||||
}
|
6
internal/shader/testdata/xorassign.go
vendored
Normal file
6
internal/shader/testdata/xorassign.go
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
package main
|
||||
|
||||
func Foo(x int) int {
|
||||
x ^= x
|
||||
return x
|
||||
}
|
Loading…
Reference in New Issue
Block a user