mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 18:02:02 +01:00
internal/shader: bug fix: treat a built-in function as an invalid argument
Closes #2965
This commit is contained in:
parent
13d15b0ed9
commit
c390f0a9fa
@ -199,7 +199,7 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar
|
|||||||
return nil, nil, nil, false
|
return nil, nil, nil, false
|
||||||
}
|
}
|
||||||
for _, expr := range es {
|
for _, expr := range es {
|
||||||
if expr.Type == shaderir.FunctionExpr {
|
if expr.Type == shaderir.FunctionExpr || expr.Type == shaderir.BuiltinFuncExpr {
|
||||||
cs.addError(e.Pos(), fmt.Sprintf("function name cannot be an argument: %s", e.Fun))
|
cs.addError(e.Pos(), fmt.Sprintf("function name cannot be an argument: %s", e.Fun))
|
||||||
return nil, nil, nil, false
|
return nil, nil, nil, false
|
||||||
}
|
}
|
||||||
|
@ -1897,6 +1897,16 @@ func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
|
|||||||
Foo(Bar())
|
Foo(Bar())
|
||||||
return color
|
return color
|
||||||
}
|
}
|
||||||
|
`)); err == nil {
|
||||||
|
t.Errorf("error must be non-nil but was nil")
|
||||||
|
}
|
||||||
|
// Issue #2965
|
||||||
|
if _, err := compileToIR([]byte(`package main
|
||||||
|
|
||||||
|
func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
|
||||||
|
abs(sign)
|
||||||
|
return color
|
||||||
|
}
|
||||||
`)); err == nil {
|
`)); err == nil {
|
||||||
t.Errorf("error must be non-nil but was nil")
|
t.Errorf("error must be non-nil but was nil")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user