mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/shader: bug fix: error on a function name in a function call
Updates #2891
This commit is contained in:
parent
60725eba86
commit
75103f39dd
@ -187,6 +187,12 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar
|
||||
cs.addError(e.Pos(), fmt.Sprintf("single-value context and multiple-value context cannot be mixed: %s", e.Fun))
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
for _, expr := range es {
|
||||
if expr.Type == shaderir.FunctionExpr {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("function name cannot be an argument: %s", e.Fun))
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
}
|
||||
args = append(args, es...)
|
||||
argts = append(argts, ts...)
|
||||
stmts = append(stmts, ss...)
|
||||
|
@ -3818,3 +3818,19 @@ func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Issue #2891
|
||||
func TestSyntaxInvalidArgument(t *testing.T) {
|
||||
if _, err := compileToIR([]byte(`package main
|
||||
|
||||
func Foo(x int) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func Bar() int {
|
||||
return Foo(Foo)
|
||||
}
|
||||
`)); err == nil {
|
||||
t.Error("compileToIR must return an error but did not")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user