mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/shader: bug fix: panic when an assignment mismatch happens
Closes #2654
This commit is contained in:
parent
56b4cdc3c4
commit
2a1d23d926
@ -639,6 +639,15 @@ func (cs *compileState) assign(block *block, fname string, pos token.Pos, lhs, r
|
|||||||
}
|
}
|
||||||
stmts = append(stmts, ss...)
|
stmts = append(stmts, ss...)
|
||||||
|
|
||||||
|
if len(l) != len(r) {
|
||||||
|
if len(r) == 0 {
|
||||||
|
cs.addError(pos, fmt.Sprintf("right-hand side (no value) used as value"))
|
||||||
|
} else {
|
||||||
|
cs.addError(pos, fmt.Sprintf("assignment mismatch: %d variables but the right-hand side has %d values", len(l), len(r)))
|
||||||
|
}
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
if l[0].Type == shaderir.Blank {
|
if l[0].Type == shaderir.Blank {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -3122,3 +3122,19 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue #2654
|
||||||
|
func TestOmittedReturnType(t *testing.T) {
|
||||||
|
if _, err := compileToIR([]byte(`package main
|
||||||
|
|
||||||
|
func foo(x vec2) {
|
||||||
|
x = bar(x)
|
||||||
|
_ = x
|
||||||
|
}
|
||||||
|
|
||||||
|
func bar(x vec2) {
|
||||||
|
return x
|
||||||
|
}`)); err == nil {
|
||||||
|
t.Error("compileToIR must return an error but did not")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user