Skip to content

Commit

Permalink
Fix bug in runtime when exporting null|undefined to interface{} (robe…
Browse files Browse the repository at this point in the history
  • Loading branch information
vanackere authored and stevenh committed Apr 24, 2017
1 parent 1861f24 commit 21ec965
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1504,3 +1504,9 @@ func TestNativeCallPointerMethodWithStructPointer(t *testing.T) {
t.Fail()
}
}

func TestNativeCallNilInterfaceArg(t *testing.T) {
vm := New()
vm.Set("f1", func(v interface{}) {})
vm.Call("f1", nil, nil)
}
6 changes: 5 additions & 1 deletion runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ func (self *_runtime) convertCallParameter(v Value, t reflect.Type) reflect.Valu
}

if t.Kind() == reflect.Interface {
iv := reflect.ValueOf(v.export())
e := v.export()
if e == nil {
return reflect.Zero(t)
}
iv := reflect.ValueOf(e)
if iv.Type().AssignableTo(t) {
return iv
}
Expand Down

0 comments on commit 21ec965

Please sign in to comment.