Skip to content

Commit 14d09aa

Browse files
committed
ci: fix failing v -cstrict vlib/v/tests/channels_test.v
1 parent 8fee140 commit 14d09aa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

vlib/v/gen/c/auto_str_struct.v

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn (g &Gen) type_to_fmt1(typ ast.Type) StrIntpType {
2424
if typ.is_ptr() && (typ.is_int_valptr() || typ.is_float_valptr()) {
2525
return .si_s
2626
} else if sym.kind in [.struct_, .array, .array_fixed, .map, .bool, .enum_, .interface_,
27-
.sum_type, .function, .alias] {
27+
.sum_type, .function, .alias, .chan] {
2828
return .si_s
2929
} else if sym.kind == .string {
3030
return .si_s
@@ -43,7 +43,6 @@ fn (g &Gen) type_to_fmt1(typ ast.Type) StrIntpType {
4343
} else if sym.kind == .i64 {
4444
return .si_i64
4545
}
46-
4746
return .si_i32
4847
}
4948

@@ -186,13 +185,15 @@ fn struct_auto_str_func1(sym &ast.TypeSymbol, field_type ast.Type, fn_name strin
186185
} else if sym.kind == .function {
187186
return '${fn_name}()'
188187
} else {
188+
if sym.kind == .chan {
189+
return '${fn_name}(it.${c_name(field_name)})'
190+
}
189191
mut method_str := 'it.${c_name(field_name)}'
190192
if sym.kind == .bool {
191193
method_str += ' ? _SLIT("true") : _SLIT("false")'
192194
} else if (field_type.is_int_valptr() || field_type.is_float_valptr())
193195
&& field_type.is_ptr() && !expects_ptr {
194-
// ptr int can be "nil", so this needs to be castet to a string
195-
196+
// ptr int can be "nil", so this needs to be casted to a string
196197
if sym.kind == .f32 {
197198
return 'str_intp(1, _MOV((StrIntpData[]){
198199
{_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
205206
fmt_type := StrIntpType.si_u64
206207
return 'str_intp(1, _MOV((StrIntpData[]){{_SLIT0, ${u32(fmt_type) | 0xfe00}, {.d_u64 = *$method_str }}}))'
207208
}
208-
209209
fmt_type := StrIntpType.si_i32
210210
return 'str_intp(1, _MOV((StrIntpData[]){{_SLIT0, ${u32(fmt_type) | 0xfe00}, {.d_i32 = *$method_str }}}))'
211211
}

vlib/v/tests/channels_test.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn test_printing_of_channels() {
2121
res := (go fn1(ch)).wait()
2222
println(res)
2323
println(ch)
24-
assert res.str().contains('another: ')
24+
assert res.str().contains('another: chan f64{cap: 100, closed: 0}')
2525
assert ch.str() == 'chan St1{cap: 10, closed: 0}'
2626
assert fch.str() == 'chan f64{cap: 100, closed: 0}'
2727
fch.close()

0 commit comments

Comments
 (0)