diff mbox

[gccgo] A type assertion with nil does not succeed

Message ID mcrzkycyzo4.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor June 30, 2010, 9:32 p.m. UTC
When doing a type assertion such as
    if v, ok := x.(t); ok { }
where x is nil, the type assertion is not considered to succeed.  This
is true even though v := x.(t) does not cause a panic.  This patch
implements that for gccgo.  Committed to gccgo branch.

Ian
diff mbox

Patch

diff -r 509de793fde1 libgo/runtime/go-convert-interface.c
--- a/libgo/runtime/go-convert-interface.c	Wed Jun 30 14:07:44 2010 -0700
+++ b/libgo/runtime/go-convert-interface.c	Wed Jun 30 14:29:05 2010 -0700
@@ -35,7 +35,7 @@ 
   if (rhs == NULL)
     {
       if (success != NULL)
-	*success = 1;
+	*success = 0;
       return NULL;
     }