mirror of
https://github.com/hanzoai/expr.git
synced 2026-09-24 16:58:58 +00:00
Fix panic in checker
This commit is contained in:
@@ -804,6 +804,9 @@ func (v *visitor) checkArguments(name string, fn reflect.Type, method bool, argu
|
||||
|
||||
func (v *visitor) ClosureNode(node *ast.ClosureNode) (reflect.Type, info) {
|
||||
t, _ := v.visit(node.Node)
|
||||
if t == nil {
|
||||
return v.error(node.Node, "closure cannot be nil")
|
||||
}
|
||||
return reflect.FuncOf([]reflect.Type{anyType}, []reflect.Type{t}, false), info{}
|
||||
}
|
||||
|
||||
|
||||
@@ -283,6 +283,7 @@ func TestCompile(t *testing.T) {
|
||||
func TestCompile_panic(t *testing.T) {
|
||||
tests := []string{
|
||||
`(TotalPosts.Profile[Authors > TotalPosts == get(nil, TotalLikes)] > Authors) ^ (TotalLikes / (Posts?.PublishDate[TotalPosts] < Posts))`,
|
||||
`one(Posts, nil)`,
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user