From 78440be2b2d54a56b6c6a97a0a0ce26ca99cfed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=C3=A4schle?= Date: Tue, 7 Apr 2020 12:39:10 +0200 Subject: [PATCH] cgen: print bool in struct correctly --- vlib/v/gen/cgen.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 7ada2d9991..af741e3569 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -2952,6 +2952,8 @@ fn (g mut Gen) gen_str_for_type(sym table.TypeSymbol, styp string) { g.definitions.write('a.' + field.name) if field.typ == table.string_type { g.definitions.write('.len, a.${field.name}.str') + } else if field.typ == table.bool_type { + g.definitions.write(' == true ? 4 : 5, a.${field.name} == true ? "true" : "false"') } if i < info.fields.len - 1 { g.definitions.write(', ') @@ -2963,6 +2965,8 @@ fn (g mut Gen) gen_str_for_type(sym table.TypeSymbol, styp string) { fn type_to_fmt(typ table.Type) string { n := int(typ) if n == table.string_type { + return '\'%.*s\'' + } else if n == table.bool_type { return '%.*s' } return '%d'