@@ -34,7 +34,7 @@ var Builtins = map[int]*Function{
34
34
if len (args ) != 1 {
35
35
return anyType , fmt .Errorf ("invalid number of arguments for len (expected 1, got %d)" , len (args ))
36
36
}
37
- switch args [0 ]. Kind ( ) {
37
+ switch kind ( args [0 ]) {
38
38
case reflect .Array , reflect .Map , reflect .Slice , reflect .String , reflect .Interface :
39
39
return integerType , nil
40
40
}
@@ -48,7 +48,7 @@ var Builtins = map[int]*Function{
48
48
if len (args ) != 1 {
49
49
return anyType , fmt .Errorf ("invalid number of arguments for abs (expected 1, got %d)" , len (args ))
50
50
}
51
- switch args [0 ]. Kind ( ) {
51
+ switch kind ( args [0 ]) {
52
52
case reflect .Float32 , reflect .Float64 , reflect .Int , reflect .Int8 , reflect .Int16 , reflect .Int32 , reflect .Int64 , reflect .Uint , reflect .Uint8 , reflect .Uint16 , reflect .Uint32 , reflect .Uint64 , reflect .Interface :
53
53
return args [0 ], nil
54
54
}
@@ -62,7 +62,7 @@ var Builtins = map[int]*Function{
62
62
if len (args ) != 1 {
63
63
return anyType , fmt .Errorf ("invalid number of arguments for int (expected 1, got %d)" , len (args ))
64
64
}
65
- switch args [0 ]. Kind ( ) {
65
+ switch kind ( args [0 ]) {
66
66
case reflect .Interface :
67
67
return integerType , nil
68
68
case reflect .Float32 , reflect .Float64 , reflect .Int , reflect .Int8 , reflect .Int16 , reflect .Int32 , reflect .Int64 , reflect .Uint , reflect .Uint8 , reflect .Uint16 , reflect .Uint32 , reflect .Uint64 :
@@ -80,7 +80,7 @@ var Builtins = map[int]*Function{
80
80
if len (args ) != 1 {
81
81
return anyType , fmt .Errorf ("invalid number of arguments for float (expected 1, got %d)" , len (args ))
82
82
}
83
- switch args [0 ]. Kind ( ) {
83
+ switch kind ( args [0 ]) {
84
84
case reflect .Interface :
85
85
return floatType , nil
86
86
case reflect .Float32 , reflect .Float64 , reflect .Int , reflect .Int8 , reflect .Int16 , reflect .Int32 , reflect .Int64 , reflect .Uint , reflect .Uint8 , reflect .Uint16 , reflect .Uint32 , reflect .Uint64 :
@@ -92,3 +92,10 @@ var Builtins = map[int]*Function{
92
92
},
93
93
},
94
94
}
95
+
96
+ func kind (t reflect.Type ) reflect.Kind {
97
+ if t == nil {
98
+ return reflect .Invalid
99
+ }
100
+ return t .Kind ()
101
+ }
0 commit comments