@@ -251,12 +251,13 @@ func (vm *VM) Run(program *Program, env interface{}) interface{} {
251
251
in := make ([]reflect.Value , call .Size )
252
252
for i := call .Size - 1 ; i >= 0 ; i -- {
253
253
param := vm .pop ()
254
- if param == nil {
255
- // In case of nil interface{} ( nil type) use this hack,
254
+ if param == nil && reflect . TypeOf ( param ) == nil {
255
+ // In case of nil value and nil type use this hack,
256
256
// otherwise reflect.Call will panic on zero value.
257
- param = reflect .ValueOf (& in ).Elem ()
257
+ in [i ] = reflect .ValueOf (& param ).Elem ()
258
+ } else {
259
+ in [i ] = reflect .ValueOf (param )
258
260
}
259
- in [i ] = reflect .ValueOf (param )
260
261
}
261
262
out := fetchFn (env , call .Name ).Call (in )
262
263
vm .push (out [0 ].Interface ())
@@ -275,12 +276,13 @@ func (vm *VM) Run(program *Program, env interface{}) interface{} {
275
276
in := make ([]reflect.Value , call .Size )
276
277
for i := call .Size - 1 ; i >= 0 ; i -- {
277
278
param := vm .pop ()
278
- if param == nil {
279
- // In case of nil interface{} ( nil type) use this hack,
279
+ if param == nil && reflect . TypeOf ( param ) == nil {
280
+ // In case of nil value and nil type use this hack,
280
281
// otherwise reflect.Call will panic on zero value.
281
- param = reflect .ValueOf (& in ).Elem ()
282
+ in [i ] = reflect .ValueOf (& param ).Elem ()
283
+ } else {
284
+ in [i ] = reflect .ValueOf (param )
282
285
}
283
- in [i ] = reflect .ValueOf (param )
284
286
}
285
287
out := fetchFn (vm .pop (), call .Name ).Call (in )
286
288
vm .push (out [0 ].Interface ())
0 commit comments