Skip to content

Commit 5ff1280

Browse files
committed
Fix type check for fast call path
1 parent aa52e70 commit 5ff1280

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

checker/checker.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ func (v *visitor) FunctionNode(node *ast.FunctionNode) reflect.Type {
331331
if !isInterface(fn) &&
332332
fn.IsVariadic() &&
333333
fn.NumIn() == inputParamsCount &&
334-
fn.NumOut() == 1 {
334+
fn.NumOut() == 1 &&
335+
fn.Out(0).Kind() == reflect.Interface {
335336
rest := fn.In(fn.NumIn() - 1) // function has only one param for functions and two for methods
336337
if rest.Kind() == reflect.Slice && rest.Elem().Kind() == reflect.Interface {
337338
node.Fast = true

expr_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,10 @@ func TestExpr(t *testing.T) {
855855
`map(filter(Tweets, {len(.Text) > 10}), {Format(.Date)})`,
856856
[]interface{}{"23 Oct 17 18:30 UTC", "23 Oct 17 18:30 UTC"},
857857
},
858+
{
859+
`Concat("a", 1, [])`,
860+
`a1[]`,
861+
},
858862
}
859863

860864
for _, tt := range tests {
@@ -1140,6 +1144,14 @@ func (*mockEnv) Variadic(x string, xs ...int) []int {
11401144
return xs
11411145
}
11421146

1147+
func (*mockEnv) Concat(list ...interface{}) string {
1148+
out := ""
1149+
for _, e := range list {
1150+
out += fmt.Sprintf("%v", e)
1151+
}
1152+
return out
1153+
}
1154+
11431155
func (*mockEnv) Float(i interface{}) float64 {
11441156
switch t := i.(type) {
11451157
case int:

0 commit comments

Comments
 (0)