From 14d09aa7c2f02c3590e1b8a87ee0484a34d6e5b4 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 1 Jun 2021 16:48:49 +0300 Subject: [PATCH] ci: fix failing `v -cstrict vlib/v/tests/channels_test.v` --- vlib/v/gen/c/auto_str_struct.v | 10 +++++----- vlib/v/tests/channels_test.v | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/vlib/v/gen/c/auto_str_struct.v b/vlib/v/gen/c/auto_str_struct.v index 3a8c70b592..b0052f0c5e 100644 --- a/vlib/v/gen/c/auto_str_struct.v +++ b/vlib/v/gen/c/auto_str_struct.v @@ -24,7 +24,7 @@ fn (g &Gen) type_to_fmt1(typ ast.Type) StrIntpType { if typ.is_ptr() && (typ.is_int_valptr() || typ.is_float_valptr()) { return .si_s } else if sym.kind in [.struct_, .array, .array_fixed, .map, .bool, .enum_, .interface_, - .sum_type, .function, .alias] { + .sum_type, .function, .alias, .chan] { return .si_s } else if sym.kind == .string { return .si_s @@ -43,7 +43,6 @@ fn (g &Gen) type_to_fmt1(typ ast.Type) StrIntpType { } else if sym.kind == .i64 { return .si_i64 } - return .si_i32 } @@ -186,13 +185,15 @@ fn struct_auto_str_func1(sym &ast.TypeSymbol, field_type ast.Type, fn_name strin } else if sym.kind == .function { return '${fn_name}()' } else { + if sym.kind == .chan { + return '${fn_name}(it.${c_name(field_name)})' + } mut method_str := 'it.${c_name(field_name)}' if sym.kind == .bool { method_str += ' ? _SLIT("true") : _SLIT("false")' } else if (field_type.is_int_valptr() || field_type.is_float_valptr()) && field_type.is_ptr() && !expects_ptr { - // ptr int can be "nil", so this needs to be castet to a string - + // ptr int can be "nil", so this needs to be casted to a string if sym.kind == .f32 { return 'str_intp(1, _MOV((StrIntpData[]){ {_SLIT0, $si_g32_code, {.d_f32 = *$method_str }} @@ -205,7 +206,6 @@ fn struct_auto_str_func1(sym &ast.TypeSymbol, field_type ast.Type, fn_name strin fmt_type := StrIntpType.si_u64 return 'str_intp(1, _MOV((StrIntpData[]){{_SLIT0, ${u32(fmt_type) | 0xfe00}, {.d_u64 = *$method_str }}}))' } - fmt_type := StrIntpType.si_i32 return 'str_intp(1, _MOV((StrIntpData[]){{_SLIT0, ${u32(fmt_type) | 0xfe00}, {.d_i32 = *$method_str }}}))' } diff --git a/vlib/v/tests/channels_test.v b/vlib/v/tests/channels_test.v index 09c38070bd..c05e658302 100644 --- a/vlib/v/tests/channels_test.v +++ b/vlib/v/tests/channels_test.v @@ -21,7 +21,7 @@ fn test_printing_of_channels() { res := (go fn1(ch)).wait() println(res) println(ch) - assert res.str().contains('another: ') + assert res.str().contains('another: chan f64{cap: 100, closed: 0}') assert ch.str() == 'chan St1{cap: 10, closed: 0}' assert fch.str() == 'chan f64{cap: 100, closed: 0}' fch.close()