From fb1ac63fb0b603de40bb0ea7664fd5d3a0d99cf8 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 21 Oct 2015 20:31:37 -0400 Subject: [PATCH] niti: protect some NPE errors Signed-off-by: Jean Privat --- src/interpreter/naive_interpreter.nit | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 -- 1.7.9.5