From 66787b05d6838def34d94015127817490f615333 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 22 Oct 2020 19:25:07 +0300 Subject: [PATCH] cgen: support most kinds of ast.PrefixExpr in gen_assert_metainfo --- vlib/v/gen/cgen.v | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 8d884cc461..b3a06dba0d 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -1370,9 +1370,21 @@ fn (mut g Gen) gen_assert_metainfo(a ast.AssertStmt) string { fn (mut g Gen) gen_assert_single_expr(e ast.Expr, t table.Type) { unknown_value := '*unknown value*' match e { - ast.CastExpr, ast.IndexExpr, ast.PrefixExpr, ast.MatchExpr { + ast.CastExpr, ast.IndexExpr, ast.MatchExpr { g.write(ctoslit(unknown_value)) } + ast.PrefixExpr { + if e.right is ast.CastExpr { + // TODO: remove this check; + // vlib/builtin/map_test.v (a map of &int, set to &int(0)) fails + // without special casing ast.CastExpr here + g.write(ctoslit(unknown_value)) + } else { + g.gen_expr_to_string(e, t) or { + g.write(ctoslit('[$err]')) + } + } + } ast.Type { sym := g.table.get_type_symbol(t) g.write(ctoslit('$sym.name'))