Skip to content

Commit aeff4c2

Browse files
committed
internal/shader: bug fix: xor-assignment operator didn't work correctly
Closes #3140
1 parent d69d079 commit aeff4c2

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

internal/shader/stmt.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
117117
if op == shaderir.And || op == shaderir.Or || op == shaderir.Xor || op == shaderir.LeftShift || op == shaderir.RightShift {
118118
if lts[0].Main != shaderir.Int && !lts[0].IsIntVector() {
119119
cs.addError(stmt.Pos(), fmt.Sprintf("invalid operation: operator %s not defined on %s", stmt.Tok, lts[0].String()))
120+
return nil, false
120121
}
121122
if rts[0].Main != shaderir.Int && !rts[0].IsIntVector() {
122123
cs.addError(stmt.Pos(), fmt.Sprintf("invalid operation: operator %s not defined on %s", stmt.Tok, rts[0].String()))
124+
return nil, false
123125
}
124-
return nil, false
125126
}
126127
if lts[0].Main == shaderir.Int && rhs[0].Const != nil {
127128
if !cs.forceToInt(stmt, &rhs[0]) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
int F0(in int l0);
2+
3+
int F0(in int l0) {
4+
l0 = (l0) ^ (l0);
5+
return l0;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package main
2+
3+
func Foo(x int) int {
4+
x ^= x
5+
return x
6+
}

0 commit comments

Comments
 (0)