1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix assert value is '*unknown value*' (#15645)

This commit is contained in:
yuyi 2022-09-03 15:38:27 +08:00 committed by GitHub
parent 4bd49a0149
commit 1ef95fdec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -147,9 +147,16 @@ fn (mut g Gen) gen_assert_single_expr(expr ast.Expr, typ ast.Type) {
// eprintln('> gen_assert_single_expr typ: $typ | expr: $expr | typeof(expr): ${typeof(expr)}')
unknown_value := '*unknown value*'
match expr {
ast.CastExpr, ast.IfExpr, ast.IndexExpr, ast.MatchExpr {
ast.CastExpr, ast.IfExpr, ast.MatchExpr {
g.write(ctoslit(unknown_value))
}
ast.IndexExpr {
if expr.index is ast.RangeExpr {
g.write(ctoslit(unknown_value))
} else {
g.gen_expr_to_string(expr, typ)
}
}
ast.PrefixExpr {
if expr.right is ast.CastExpr {
// TODO: remove this check;