From: Jean Privat Date: Thu, 22 Oct 2015 00:31:37 +0000 (-0400) Subject: niti: protect some NPE errors X-Git-Tag: v0.7.9~10^2~3 X-Git-Url: http://nitlanguage.org niti: protect some NPE errors Signed-off-by: Jean Privat --- diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index 82800cf..8b0f291 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -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