v_expr
to explain_str
and protect null values
# Add the value of `v_expr` to `explain_str` and protect null values
fun explain_expr(v_expr: AExpr)
do
var mtype = v_expr.mtype
if mtype == null then
explain_string "<unexpected error>"
return
end
# Set the expression value aside
var old_parent = v_expr.parent
var expr = v_expr.make_var_read
if old_parent != null then old_parent.validate
# Protect nullable types
if mtype isa MNullType then
explain_string "null"
return
else if mtype isa MNullableType then
var e = new AOrElseExpr
e.n_expr = expr
e.n_expr2 = explain_string("null", false)
e.location = assert_node.location
e.mtype = mmodule.object_type
explain_str.n_exprs.add e
return
end
explain_str.n_exprs.add expr
end
src/frontend/explain_assert.nit:138,2--168,4