1
0
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:
Felipe Pena 2023-03-07 13:13:19 -03:00 committed by GitHub
parent 32751440b6
commit 792b822091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -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('*',
'')
} }
} }
} }

View 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
}