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
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
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(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
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
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
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