ebiten: Bug fix: Test failuer (TestShaderWrongReturn)

This commit is contained in:
Hajime Hoshi 2020-09-12 18:36:22 +09:00
parent d001f49ad7
commit a0db26f234
2 changed files with 8 additions and 4 deletions

View File

@ -404,8 +404,12 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
cs.addError(r.Pos(), "single-value context and multiple-value context cannot be mixed")
return nil, false
}
if len(exprs) != len(outParams) {
}
// TODO: Is this logic really true?
if len(exprs) > 1 || len(outParams) > 1 {
if len(exprs) != len(outParams) && len(stmt.Results) != len(outParams) {
cs.addError(stmt.Pos(), fmt.Sprintf("the number of returning variables must be %d but %d", len(outParams), len(stmt.Results)))
return nil, false
}
}

View File

@ -244,7 +244,7 @@ func TestShaderWrongReturn(t *testing.T) {
if _, err := NewShader([]byte(`package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
return 0.0;
return 0.0
}
`)); err == nil {
t.Errorf("error must be non-nil but was nil")
@ -253,11 +253,11 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
if _, err := NewShader([]byte(`package main
func Foo() (float, float) {
return 0;
return 0
}
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
return vec4(0);
return vec4(0)
}
`)); err == nil {
t.Errorf("error must be non-nil but was nil")