@@ -604,11 +604,11 @@ func (v *visitor) BuiltinNode(node *ast.BuiltinNode) (reflect.Type, info) {
604
604
closure .NumIn () == 1 && isAny (closure .In (0 )) {
605
605
606
606
if ! isBool (closure .Out (0 )) && ! isAny (closure .Out (0 )) {
607
- return v .error (node .Arguments [1 ], "closure should return boolean (got %v)" , closure .Out (0 ).String ())
607
+ return v .error (node .Arguments [1 ], "predicate should return boolean (got %v)" , closure .Out (0 ).String ())
608
608
}
609
609
return boolType , info {}
610
610
}
611
- return v .error (node .Arguments [1 ], "closure should has one input and one output param" )
611
+ return v .error (node .Arguments [1 ], "predicate should has one input and one output param" )
612
612
613
613
case "filter" :
614
614
collection , _ := v .visit (node .Arguments [0 ])
@@ -625,14 +625,14 @@ func (v *visitor) BuiltinNode(node *ast.BuiltinNode) (reflect.Type, info) {
625
625
closure .NumIn () == 1 && isAny (closure .In (0 )) {
626
626
627
627
if ! isBool (closure .Out (0 )) && ! isAny (closure .Out (0 )) {
628
- return v .error (node .Arguments [1 ], "closure should return boolean (got %v)" , closure .Out (0 ).String ())
628
+ return v .error (node .Arguments [1 ], "predicate should return boolean (got %v)" , closure .Out (0 ).String ())
629
629
}
630
630
if isAny (collection ) {
631
631
return arrayType , info {}
632
632
}
633
633
return reflect .SliceOf (collection .Elem ()), info {}
634
634
}
635
- return v .error (node .Arguments [1 ], "closure should has one input and one output param" )
635
+ return v .error (node .Arguments [1 ], "predicate should has one input and one output param" )
636
636
637
637
case "map" :
638
638
collection , _ := v .visit (node .Arguments [0 ])
@@ -650,7 +650,7 @@ func (v *visitor) BuiltinNode(node *ast.BuiltinNode) (reflect.Type, info) {
650
650
651
651
return reflect .SliceOf (closure .Out (0 )), info {}
652
652
}
653
- return v .error (node .Arguments [1 ], "closure should has one input and one output param" )
653
+ return v .error (node .Arguments [1 ], "predicate should has one input and one output param" )
654
654
655
655
case "count" :
656
656
collection , _ := v .visit (node .Arguments [0 ])
@@ -666,14 +666,14 @@ func (v *visitor) BuiltinNode(node *ast.BuiltinNode) (reflect.Type, info) {
666
666
closure .NumOut () == 1 &&
667
667
closure .NumIn () == 1 && isAny (closure .In (0 )) {
668
668
if ! isBool (closure .Out (0 )) && ! isAny (closure .Out (0 )) {
669
- return v .error (node .Arguments [1 ], "closure should return boolean (got %v)" , closure .Out (0 ).String ())
669
+ return v .error (node .Arguments [1 ], "predicate should return boolean (got %v)" , closure .Out (0 ).String ())
670
670
}
671
671
672
672
return integerType , info {}
673
673
}
674
- return v .error (node .Arguments [1 ], "closure should has one input and one output param" )
674
+ return v .error (node .Arguments [1 ], "predicate should has one input and one output param" )
675
675
676
- case "find" :
676
+ case "find" , "findLast" :
677
677
collection , _ := v .visit (node .Arguments [0 ])
678
678
if ! isArray (collection ) && ! isAny (collection ) {
679
679
return v .error (node .Arguments [0 ], "builtin %v takes only array (got %v)" , node .Name , collection )
@@ -688,16 +688,16 @@ func (v *visitor) BuiltinNode(node *ast.BuiltinNode) (reflect.Type, info) {
688
688
closure .NumIn () == 1 && isAny (closure .In (0 )) {
689
689
690
690
if ! isBool (closure .Out (0 )) && ! isAny (closure .Out (0 )) {
691
- return v .error (node .Arguments [1 ], "closure should return boolean (got %v)" , closure .Out (0 ).String ())
691
+ return v .error (node .Arguments [1 ], "predicate should return boolean (got %v)" , closure .Out (0 ).String ())
692
692
}
693
693
if isAny (collection ) {
694
694
return anyType , info {}
695
695
}
696
696
return collection .Elem (), info {}
697
697
}
698
- return v .error (node .Arguments [1 ], "closure should has one input and one output param" )
698
+ return v .error (node .Arguments [1 ], "predicate should has one input and one output param" )
699
699
700
- case "findIndex" :
700
+ case "findIndex" , "findLastIndex" :
701
701
collection , _ := v .visit (node .Arguments [0 ])
702
702
if ! isArray (collection ) && ! isAny (collection ) {
703
703
return v .error (node .Arguments [0 ], "builtin %v takes only array (got %v)" , node .Name , collection )
@@ -712,12 +712,11 @@ func (v *visitor) BuiltinNode(node *ast.BuiltinNode) (reflect.Type, info) {
712
712
closure .NumIn () == 1 && isAny (closure .In (0 )) {
713
713
714
714
if ! isBool (closure .Out (0 )) && ! isAny (closure .Out (0 )) {
715
- return v .error (node .Arguments [1 ], "closure should return boolean (got %v)" , closure .Out (0 ).String ())
715
+ return v .error (node .Arguments [1 ], "predicate should return boolean (got %v)" , closure .Out (0 ).String ())
716
716
}
717
717
return integerType , info {}
718
718
}
719
- return v .error (node .Arguments [1 ], "closure should has one input and one output param" )
720
-
719
+ return v .error (node .Arguments [1 ], "predicate should has one input and one output param" )
721
720
}
722
721
723
722
if id , ok := builtin .Index [node .Name ]; ok {
0 commit comments