From 956651384c919e05c0994c3b8270ed05f495b71e Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 14 Apr 2020 13:44:19 +0800 Subject: [PATCH] cgen: fix math/complex_test.v --- cmd/tools/vtest-fixed.v | 1 - vlib/v/gen/cgen.v | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/tools/vtest-fixed.v b/cmd/tools/vtest-fixed.v index fca264e19b..8f7cf9b640 100644 --- a/cmd/tools/vtest-fixed.v +++ b/cmd/tools/vtest-fixed.v @@ -16,7 +16,6 @@ const ( 'vlib/eventbus/eventbus_test.v', 'vlib/flag/flag_test.v', 'vlib/json/json_test.v', - 'vlib/math/complex/complex_test.v', 'vlib/net/ftp/ftp_test.v', 'vlib/net/http/http_httpbin_test.v', 'vlib/net/http/http_test.v', diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 24a1cfd25e..0fa8d215fc 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -2189,9 +2189,11 @@ fn (g mut Gen) string_inter_literal(node ast.StringInterLiteral) { verror('only V strings can be formatted with a ${sfmt} format') } g.write('%' + sfmt[1..]) - } else if node.expr_types[i] in [table.string_type, table.bool_type, table.f32_type, - table.f64_type] || sym.kind in [.enum_, .array, .array_fixed] { + } else if node.expr_types[i] in [table.string_type, table.bool_type] || + sym.kind in [.enum_, .array, .array_fixed] { g.write('%.*s') + } else if node.expr_types[i] in [table.f32_type, table.f64_type] { + g.write('%f') } else { g.write('%d') } @@ -2219,6 +2221,8 @@ fn (g mut Gen) string_inter_literal(node ast.StringInterLiteral) { g.write(' ? 4 : 5, ') g.expr(expr) g.write(' ? "true" : "false"') + } else if node.expr_types[i] in [table.f32_type, table.f64_type] { + g.expr(expr) } else { sym := g.table.get_type_symbol(node.expr_types[i]) if sym.kind == .enum_ { @@ -2252,8 +2256,7 @@ fn (g mut Gen) string_inter_literal(node ast.StringInterLiteral) { g.enum_expr(expr) g.write('"') } - } else if node.expr_types[i] in [table.f32_type, table.f64_type, table.array_type, - table.map_type] || sym.kind in [.array, .array_fixed] { + } else if sym.kind in [.array, .array_fixed] { styp := g.typ(node.expr_types[i]) g.write('${styp}_str(') g.expr(expr)