diff --git a/internal/shader/shader.go b/internal/shader/shader.go index e57619b3f..6ecbed8da 100644 --- a/internal/shader/shader.go +++ b/internal/shader/shader.go @@ -322,11 +322,9 @@ func (cs *compileState) parseDecl(b *block, d ast.Decl) ([]shaderir.Stmt, bool) continue } - for _, v := range vs { - b.addNamedLocalVariable(v.name, v.typ, d.Pos()) - } - base := b.totalLocalVariableNum() + b.vars = append(b.vars, vs...) + if len(inits) > 0 { for i := range vs { stmts = append(stmts, shaderir.Stmt{ diff --git a/shader_test.go b/shader_test.go index de69a6e9b..12299c4e6 100644 --- a/shader_test.go +++ b/shader_test.go @@ -588,26 +588,6 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { `)); err != nil { 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) {