Fix panic in checker

This commit is contained in:
Anton Medvedev
2023-08-17 23:16:33 +02:00
parent 1334af4cf7
commit cd03cb4c30
2 changed files with 4 additions and 0 deletions
+3
View File
@@ -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{}
}
+1
View File
@@ -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) {