frontent/serialization: fix warnings
[nit.git] / src / frontend / serialization_phase.nit
index ddb0cce..d15f490 100644 (file)
@@ -121,7 +121,7 @@ private class SerializationPhasePreModel
                if not node isa AModuledecl then
                        var up_serialize = false
                        var up: nullable ANode = node
-                       loop
+                       while up != null do
                                up = up.parent
                                if up == null then
                                        break
@@ -237,11 +237,14 @@ do
 
                        var n_type = attribute.n_type
                        var type_name
+                       var type_name_pretty
                        if n_type == null then
                                # Use a place holder, we will replace it with the inferred type after the model phases
                                type_name = toolcontext.place_holder_type_name
+                               type_name_pretty = "Unknown type"
                        else
                                type_name = n_type.type_name
+                               type_name_pretty = type_name
                        end
                        var name = attribute.name
 
@@ -254,8 +257,7 @@ do
        var {{{name}}} = v.deserialize_attribute("{{{attribute.serialize_name}}}")
        if not {{{name}}} isa {{{type_name}}} then
                # Check if it was a subjectent error
-               v.errors.add new AttributeTypeError("TODO remove this arg on c_src regen",
-                       self, "{{{attribute.serialize_name}}}", {{{name}}}, "{{{type_name}}}")
+               v.errors.add new AttributeTypeError(self, "{{{attribute.serialize_name}}}", {{{name}}}, "{{{type_name_pretty}}}")
 
                # Clear subjacent error
                if v.keep_going == false then return
@@ -297,7 +299,9 @@ do
                end
 
                for nclassdef in nclassdefs do
-                       var name = nclassdef.n_qid.n_id.text
+                       var n_qid = nclassdef.n_qid
+                       if n_qid == null then continue
+                       var name = n_qid.n_id.text
                        if nclassdef.n_formaldefs.is_empty and
                           nclassdef.n_classkind isa AConcreteClasskind then
 
@@ -385,9 +389,9 @@ redef class AModule
        private fun deserializer_nclassdef: nullable AStdClassdef
        do
                for nclassdef in n_classdefs do
-                       if nclassdef isa AStdClassdef and nclassdef.n_qid.n_id.text == "Deserializer" then
-                               return nclassdef
-                       end
+                       if not nclassdef isa AStdClassdef then continue
+                       var n_qid = nclassdef.n_qid
+                       if n_qid != null and n_qid.n_id.text == "Deserializer" then return nclassdef
                end
 
                return null
@@ -395,7 +399,11 @@ redef class AModule
 
        private var inits_to_retype = new Array[AMethPropdef]
 
-       redef fun is_serialize do return n_moduledecl != null and n_moduledecl.is_serialize
+       redef fun is_serialize
+       do
+               var n_moduledecl = n_moduledecl
+               return n_moduledecl != null and n_moduledecl.is_serialize
+       end
 end
 
 redef class AStdClassdef