mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
parent
d999b4dc8e
commit
5f81065d78
@ -235,6 +235,13 @@ func (cs *compileState) parse(f *ast.File) {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, f := range cs.funcs {
|
||||
if f.name == n {
|
||||
cs.addError(d.Pos(), fmt.Sprintf("redeclared function: %s", n))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
inParams, outParams := cs.parseFuncParams(&cs.global, fd)
|
||||
var inT, outT []shaderir.Type
|
||||
for _, v := range inParams {
|
||||
|
@ -251,6 +251,23 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
}
|
||||
}
|
||||
|
||||
func TestShaderDuplicatedFunctions(t *testing.T) {
|
||||
if _, err := NewShader([]byte(`package main
|
||||
|
||||
func Foo() {
|
||||
}
|
||||
|
||||
func Foo() {
|
||||
}
|
||||
|
||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
return vec4(0)
|
||||
}
|
||||
`)); err == nil {
|
||||
t.Errorf("error must be non-nil but was nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestShaderNoMain(t *testing.T) {
|
||||
if _, err := NewShader([]byte(`package main
|
||||
`)); err == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user