From 94d0bd53433d88d2e4c3b9e952587b14f44ce166 Mon Sep 17 00:00:00 2001 From: Shaun Cooley Date: Sat, 20 Nov 2021 15:13:40 -0800 Subject: [PATCH] fix: handling of nil passed as an arg to a typed interface parameter for #160 --- handler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/handler.go b/handler.go index 783823a..aec375f 100644 --- a/handler.go +++ b/handler.go @@ -104,7 +104,11 @@ func (h *reflectFunc) fnArgs(msg *Message) ([]reflect.Value, error) { inType := h.ft.In(inStart + i) if inType.Kind() == reflect.Interface { - if !v.Type().Implements(inType) { + // If the input value is an untyped nil, simply create a new + // typed nil so that the subsequent .Call() works + if !v.IsValid() { + v = reflect.Zero(inType) + } else if !v.Type().Implements(inType) { hasWrongType = true break }