From ca1293fde0d21b6c23f41ad6348564961844ed0d Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 17 Jun 2015 21:51:44 -0400 Subject: [PATCH] typing: warn about useless null when the target is always `null` Signed-off-by: Jean Privat --- src/semantize/typing.nit | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/semantize/typing.nit b/src/semantize/typing.nit index f231d4b..86e5bcb 100644 --- a/src/semantize/typing.nit +++ b/src/semantize/typing.nit @@ -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 -- 1.7.9.5