Skip to content

Commit

Permalink
cgen: fix printing of floating point values in asserts (#21538)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed May 23, 2024
1 parent 463125e commit 2b1be90
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion vlib/v/gen/c/assert.v
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,14 @@ 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.MatchExpr {
ast.CastExpr {
if typ.is_float() || g.table.final_sym(typ).is_float() {
g.gen_expr_to_string(expr.expr, typ)
} else {
g.write(ctoslit(unknown_value))
}
}
ast.IfExpr, ast.MatchExpr {
g.write(ctoslit(unknown_value))
}
ast.IndexExpr {
Expand Down

0 comments on commit 2b1be90

Please sign in to comment.