-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicitly convert assignable nil interface values (#49)
The reflect package has a bug (golang/go#22143). Let R and T both be interface types and R be assignable to T. Let F be a function that takes T as its argument. The Go language lets you directly call F with a nil T or a nil R (since R is assignable to T) without any special handling. Currently, reflect allows you to call F with a nil T, but panics when calling F with a nil R. To avoid this panic, we explicitly check for the condition where a value: * is an interface type * is nil * is not exactly same as type T and re-create the value as a nil interface of type T.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters