mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
a98376025e
commit
6e4dc82f28
@ -59,7 +59,7 @@ pub:
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_channel[T](n u32) &Channel {
|
pub fn new_channel[T](n u32) &Channel {
|
||||||
st := sizeof(T)
|
st := if sizeof(T) > 0 { sizeof(T) } else { 1 }
|
||||||
if isreftype(T) {
|
if isreftype(T) {
|
||||||
return new_channel_st(n, st)
|
return new_channel_st(n, st)
|
||||||
} else {
|
} else {
|
||||||
|
8
vlib/sync/empty_struct_chan_init_test.v
Normal file
8
vlib/sync/empty_struct_chan_init_test.v
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
struct User {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_empty_struct_chan_init() {
|
||||||
|
user_ch := chan User{cap: 10}
|
||||||
|
println(user_ch)
|
||||||
|
assert true
|
||||||
|
}
|
@ -3095,7 +3095,9 @@ fn (mut g Gen) expr(node_ ast.Expr) {
|
|||||||
}
|
}
|
||||||
g.write(', sizeof(')
|
g.write(', sizeof(')
|
||||||
g.write(elem_typ_str)
|
g.write(elem_typ_str)
|
||||||
g.write('))')
|
g.write(')>0 ? sizeof(')
|
||||||
|
g.write(elem_typ_str)
|
||||||
|
g.write(') : 1)')
|
||||||
}
|
}
|
||||||
ast.CharLiteral {
|
ast.CharLiteral {
|
||||||
g.char_literal(node)
|
g.char_literal(node)
|
||||||
|
Loading…
Reference in New Issue
Block a user