mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix dump(option_value)
inside a generic function (#17537)
This commit is contained in:
parent
32751440b6
commit
792b822091
@ -20,7 +20,8 @@ fn (mut g Gen) dump_expr(node ast.DumpExpr) {
|
|||||||
if node.expr is ast.Ident {
|
if node.expr is ast.Ident {
|
||||||
// var
|
// var
|
||||||
if node.expr.info is ast.IdentVar && node.expr.language == .v {
|
if node.expr.info is ast.IdentVar && node.expr.language == .v {
|
||||||
name = g.typ(g.unwrap_generic(node.expr.info.typ)).replace('*', '')
|
name = g.typ(g.unwrap_generic(node.expr.info.typ.clear_flag(.shared_f).clear_flag(.option).clear_flag(.result))).replace('*',
|
||||||
|
'')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
vlib/v/tests/option_array_dump_in_generic_fn_test.v
Normal file
15
vlib/v/tests/option_array_dump_in_generic_fn_test.v
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
fn abc[T]() []int {
|
||||||
|
a := []?int{len: 2}
|
||||||
|
mut s := []int{}
|
||||||
|
for v in a {
|
||||||
|
s << dump(v)
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_main() {
|
||||||
|
arr := abc[int]()
|
||||||
|
assert arr.len == 2
|
||||||
|
assert arr[0] == 0
|
||||||
|
assert arr[1] == 0
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user