mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
This commit is contained in:
parent
e5100a8f73
commit
9fcca599a5
2 changed files with 41 additions and 2 deletions
|
@ -5444,7 +5444,7 @@ fn (mut g Gen) ident(node ast.Ident) {
|
|||
}
|
||||
if i == 0 && node.obj.ct_type_var != .smartcast && node.obj.is_unwrapped {
|
||||
dot := if (!node.obj.ct_type_unwrapped && !node.obj.orig_type.is_ptr()
|
||||
&& obj_sym.is_heap())
|
||||
&& !node.obj.orig_type.has_flag(.generic) && obj_sym.is_heap())
|
||||
|| node.obj.orig_type.has_flag(.option_mut_param_t) {
|
||||
'->'
|
||||
} else {
|
||||
|
@ -6727,7 +6727,7 @@ fn (mut g Gen) write_types(symbols []&ast.TypeSymbol) {
|
|||
for opt_field in opt_fields {
|
||||
field_sym := g.table.final_sym(opt_field.typ)
|
||||
arr := field_sym.info as ast.ArrayFixed
|
||||
if !arr.elem_type.has_flag(.option) {
|
||||
if !arr.elem_type.has_flag(.option) || arr.elem_type.has_flag(.generic) {
|
||||
continue
|
||||
}
|
||||
styp := field_sym.cname
|
||||
|
|
39
vlib/v/tests/options/option_generic_array_field_test.v
Normal file
39
vlib/v/tests/options/option_generic_array_field_test.v
Normal file
|
@ -0,0 +1,39 @@
|
|||
module main
|
||||
|
||||
@[heap]
|
||||
struct FLQueue[T] {
|
||||
mut:
|
||||
inner [8]?T
|
||||
}
|
||||
|
||||
fn (mut f FLQueue[T]) put[T](element T) {
|
||||
for index, item in f.inner {
|
||||
if item == none {
|
||||
f.inner[index] = element
|
||||
return
|
||||
}
|
||||
}
|
||||
panic('put: No free slot')
|
||||
}
|
||||
|
||||
fn (mut f FLQueue[T]) get[T]() ?T {
|
||||
for item in f.inner {
|
||||
if item != none {
|
||||
return item
|
||||
}
|
||||
}
|
||||
return none
|
||||
}
|
||||
|
||||
@[heap]
|
||||
struct Thread {
|
||||
stack [1024]u8
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
mut q := FLQueue[Thread]{}
|
||||
t := Thread{}
|
||||
q.put(t)
|
||||
p := q.get()
|
||||
println(p)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue