Skip to content

Commit 66787b0

Browse files
committed
cgen: support most kinds of ast.PrefixExpr in gen_assert_metainfo
1 parent f7698ea commit 66787b0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

vlib/v/gen/cgen.v

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,9 +1370,21 @@ fn (mut g Gen) gen_assert_metainfo(a ast.AssertStmt) string {
13701370
fn (mut g Gen) gen_assert_single_expr(e ast.Expr, t table.Type) {
13711371
unknown_value := '*unknown value*'
13721372
match e {
1373-
ast.CastExpr, ast.IndexExpr, ast.PrefixExpr, ast.MatchExpr {
1373+
ast.CastExpr, ast.IndexExpr, ast.MatchExpr {
13741374
g.write(ctoslit(unknown_value))
13751375
}
1376+
ast.PrefixExpr {
1377+
if e.right is ast.CastExpr {
1378+
// TODO: remove this check;
1379+
// vlib/builtin/map_test.v (a map of &int, set to &int(0)) fails
1380+
// without special casing ast.CastExpr here
1381+
g.write(ctoslit(unknown_value))
1382+
} else {
1383+
g.gen_expr_to_string(e, t) or {
1384+
g.write(ctoslit('[$err]'))
1385+
}
1386+
}
1387+
}
13761388
ast.Type {
13771389
sym := g.table.get_type_symbol(t)
13781390
g.write(ctoslit('$sym.name'))

0 commit comments

Comments
 (0)