typing: new warning useless-null-test that detect == and != between non-nullables...
authorJean Privat <jean@pryen.org>
Sat, 11 Oct 2014 16:31:00 +0000 (12:31 -0400)
committerJean Privat <jean@pryen.org>
Sat, 11 Oct 2014 17:23:01 +0000 (13:23 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/semantize/typing.nit

index f254292..c581f47 100644 (file)
@@ -206,7 +206,11 @@ private class TypeVisitor
 
                if not mtype2 isa MNullType then return
 
+               # Check of useless null
                if not mtype isa MNullableType then
+                       if not anchor_to(mtype) isa MNullableType then
+                               modelbuilder.warning(anode, "useless-null-test", "Warning: expression is not null, since it is a `{mtype}`.")
+                       end
                        return
                end