src: do not crash if there is not MAttributeDef in AAttrPropdef (abstract attribute)
authorJean Privat <jean@pryen.org>
Thu, 26 Feb 2015 13:02:37 +0000 (20:02 +0700)
committerJean Privat <jean@pryen.org>
Thu, 26 Feb 2015 13:02:37 +0000 (20:02 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

src/interpreter/naive_interpreter.nit
src/semantize/typing.nit

index 47b02cd..dd61428 100644 (file)
@@ -1166,7 +1166,9 @@ redef class AAttrPropdef
                        evaluate_expr(v, recv)
                        return
                end
-               var mtype = self.mpropdef.static_mtype.as(not null)
+               var mpropdef = self.mpropdef
+               if mpropdef == null then return
+               var mtype = mpropdef.static_mtype.as(not null)
                mtype = mtype.anchor_to(v.mainmodule, recv.mtype.as(MClassType))
                if mtype isa MNullableType then
                        v.write_attribute(self.mpropdef.mproperty, recv, v.null_instance)
index 343edbd..6a6d943 100644 (file)
@@ -597,6 +597,8 @@ end
 redef class AAttrPropdef
        redef fun do_typing(modelbuilder: ModelBuilder)
        do
+               if not has_value then return
+
                var mpropdef = self.mpropdef.as(not null)
                var v = new TypeVisitor(modelbuilder, mpropdef.mclassdef.mmodule, mpropdef)
                self.selfvariable = v.selfvariable