typing: warn about useless null when the target is always `null`
authorJean Privat <jean@pryen.org>
Thu, 18 Jun 2015 01:51:44 +0000 (21:51 -0400)
committerJean Privat <jean@pryen.org>
Thu, 18 Jun 2015 03:09:10 +0000 (23:09 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/semantize/typing.nit

index f231d4b..86e5bcb 100644 (file)
@@ -217,6 +217,10 @@ private class TypeVisitor
        # Else return true.
        fun check_can_be_null(anode: ANode, mtype: MType): Bool
        do
+               if mtype isa MNullType then
+                       modelbuilder.warning(anode, "useless-null-test", "Warning: expression is always `null`.")
+                       return true
+               end
                if can_be_null(mtype) then return true
 
                if mtype isa MFormalType then