typing: handle `a == null` when `a` is null
authorJean Privat <jean@pryen.org>
Sat, 11 Apr 2015 17:09:04 +0000 (00:09 +0700)
committerJean Privat <jean@pryen.org>
Tue, 14 Apr 2015 09:31:36 +0000 (16:31 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

src/semantize/typing.nit

index ee93c2e..6727d02 100644 (file)
@@ -239,12 +239,16 @@ private class TypeVisitor
 
                if not mtype2 isa MNullType then return
 
-               if mtype isa MNullType then return
-
                # Check of useless null
                if not check_can_be_null(anode.n_expr, mtype) then return
 
-               mtype = mtype.as_notnull
+               if mtype isa MNullType then
+                       # Because of type adaptation, we cannot just stop here
+                       # so return use `null` as a bottom type that will be merged easily (cf) `merge_types`
+                       mtype = null
+               else
+                       mtype = mtype.as_notnull
+               end
 
                # Check for type adaptation
                var variable = anode.n_expr.its_variable