niti: protect some NPE errors
authorJean Privat <jean@pryen.org>
Thu, 22 Oct 2015 00:31:37 +0000 (20:31 -0400)
committerJean Privat <jean@pryen.org>
Thu, 22 Oct 2015 00:31:37 +0000 (20:31 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/interpreter/naive_interpreter.nit

index 82800cf..8b0f291 100644 (file)
@@ -157,7 +157,7 @@ class NaiveInterpreter
                        n.debug("inconsitance: no value and not escaping.")
                end
                var implicit_cast_to = n.implicit_cast_to
-               if implicit_cast_to != null then
+               if i != null and implicit_cast_to != null then
                        var mtype = self.unanchor_type(implicit_cast_to)
                        if not self.is_subtype(i.mtype, mtype) then n.fatal(self, "Cast failed. Expected `{implicit_cast_to}`, got `{i.mtype}`")
                end
@@ -566,6 +566,7 @@ class NaiveInterpreter
        # Use this method, instead of `send` to execute and control the additional behavior of the call-sites
        fun callsite(callsite: nullable CallSite, arguments: Array[Instance]): nullable Instance
        do
+               if callsite == null then return null
                var initializers = callsite.mpropdef.initializers
                if not initializers.is_empty then
                        var recv = arguments.first