mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
shader: Bug fix: Checking unused variables defined with var
This commit is contained in:
parent
e764b3a425
commit
4d3d3134d5
@ -322,9 +322,11 @@ func (cs *compileState) parseDecl(b *block, d ast.Decl) ([]shaderir.Stmt, bool)
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
base := b.totalLocalVariableNum()
|
for _, v := range vs {
|
||||||
b.vars = append(b.vars, vs...)
|
b.addNamedLocalVariable(v.name, v.typ, d.Pos())
|
||||||
|
}
|
||||||
|
|
||||||
|
base := b.totalLocalVariableNum()
|
||||||
if len(inits) > 0 {
|
if len(inits) > 0 {
|
||||||
for i := range vs {
|
for i := range vs {
|
||||||
stmts = append(stmts, shaderir.Stmt{
|
stmts = append(stmts, shaderir.Stmt{
|
||||||
|
@ -588,6 +588,26 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
`)); err != nil {
|
`)); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err := NewShader([]byte(`package main
|
||||||
|
|
||||||
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
|
var a int
|
||||||
|
return vec4(0)
|
||||||
|
}
|
||||||
|
`)); err == nil {
|
||||||
|
t.Errorf("error must be non-nil but was nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := NewShader([]byte(`package main
|
||||||
|
|
||||||
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
|
var a, b int
|
||||||
|
return vec4(0)
|
||||||
|
}
|
||||||
|
`)); err == nil {
|
||||||
|
t.Errorf("error must be non-nil but was nil")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShaderBlankLhs(t *testing.T) {
|
func TestShaderBlankLhs(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user