From ac971f77c55b5f984486228bde21729c2c70b83b Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 17 Sep 2020 17:32:07 +0900 Subject: [PATCH] Revert "shader: Bug fix: Checking unused variables defined with var" This reverts commit 4d3d3134d58990fe8bef8fb24836a958df40f01e. Reason: Test failures --- internal/shader/shader.go | 6 ++---- shader_test.go | 20 -------------------- 2 files changed, 2 insertions(+), 24 deletions(-) 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) {