Permalink
Browse files

compiler/natives/src/reflect: Return true in IsNil for implicitly con…

…verted nil interface.

Not yet sure if this is the right/best fix, needs investigation. But it
allows the TestCallConvert test to pass without breaking any others.

Related to golang/go@eafa29b.

Fixes:

	$ gopherjs test -v --run=TestCallConvert reflect
	=== RUN   TestCallConvert
	--- FAIL: TestCallConvert (0.10s)
		all_test.go:1639: expected [nil], got [<io.Reader Value>]
	FAIL
	FAIL	reflect	0.808s
  • Loading branch information...
dmitshur committed Dec 14, 2017
1 parent b5ab82f commit 39de26c1535f5f4d05d1c67c0ea51ba4fb0f8a31
Showing with 2 additions and 2 deletions.
  1. +2 −2 compiler/natives/src/reflect/reflect.go
@@ -918,7 +918,7 @@ func (v Value) Elem() Value {
switch k := v.kind(); k {
case Interface:
val := v.object()
if val == js.Global.Get("$ifaceNil") {
if val == js.Global.Get("$ifaceNil") { // TODO: Do we need to check for val == js.InternalObject(0) here?
return Value{}
}
typ := reflectType(val.Get("constructor"))
@@ -1102,7 +1102,7 @@ func (v Value) IsNil() bool {
case Map:
return v.object() == js.InternalObject(false)
case Interface:
return v.object() == js.Global.Get("$ifaceNil")
return v.object() == js.Global.Get("$ifaceNil") || v.object() == js.InternalObject(0)
default:
panic(&ValueError{"reflect.Value.IsNil", k})
}

0 comments on commit 39de26c

Please sign in to comment.