From 1ef95fdec62a4030ff5e798d12d40ec3dd90fcd3 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sat, 3 Sep 2022 15:38:27 +0800 Subject: [PATCH] cgen: fix assert value is '*unknown value*' (#15645) --- vlib/v/gen/c/assert.v | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vlib/v/gen/c/assert.v b/vlib/v/gen/c/assert.v index a1d6e94f8..eed866219 100644 --- a/vlib/v/gen/c/assert.v +++ b/vlib/v/gen/c/assert.v @@ -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; -- 2.30.2