Skip to content

Commit 87e38b1

Browse files
committed
Fix panic in checker
1 parent 39c9df6 commit 87e38b1

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

checker/checker.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,9 @@ func (v *visitor) checkArguments(name string, fn reflect.Type, method bool, argu
804804

805805
func (v *visitor) ClosureNode(node *ast.ClosureNode) (reflect.Type, info) {
806806
t, _ := v.visit(node.Node)
807+
if t == nil {
808+
return v.error(node.Node, "closure cannot be nil")
809+
}
807810
return reflect.FuncOf([]reflect.Type{anyType}, []reflect.Type{t}, false), info{}
808811
}
809812

compiler/compiler_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ func TestCompile(t *testing.T) {
283283
func TestCompile_panic(t *testing.T) {
284284
tests := []string{
285285
`(TotalPosts.Profile[Authors > TotalPosts == get(nil, TotalLikes)] > Authors) ^ (TotalLikes / (Posts?.PublishDate[TotalPosts] < Posts))`,
286+
`one(Posts, nil)`,
286287
}
287288
for _, test := range tests {
288289
t.Run(test, func(t *testing.T) {

0 commit comments

Comments
 (0)