cgen: support most kinds of ast.PrefixExpr in gen_assert_metainfo

pull/6672/head
Delyan Angelov 2020-10-22 19:25:07 +03:00
parent f7698ea160
commit 66787b05d6
1 changed files with 13 additions and 1 deletions

View File

@ -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'))