cgen: fix generic fn with anon fn in body (#12647)
parent
988779846f
commit
2144471ce1
|
@ -217,7 +217,9 @@ fn (mut g Gen) gen_fn_decl(node &ast.FnDecl, skip bool) {
|
||||||
}
|
}
|
||||||
mut type_name := g.typ(node.return_type)
|
mut type_name := g.typ(node.return_type)
|
||||||
|
|
||||||
|
if node.generic_names.len > 0 {
|
||||||
name = g.generic_fn_name(g.cur_concrete_types, name, true)
|
name = g.generic_fn_name(g.cur_concrete_types, name, true)
|
||||||
|
}
|
||||||
|
|
||||||
if g.pref.translated && node.attrs.contains('c') {
|
if g.pref.translated && node.attrs.contains('c') {
|
||||||
// This fixes unknown symbols errors when building separate .c => .v files
|
// This fixes unknown symbols errors when building separate .c => .v files
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
fn foo<T>() string {
|
||||||
|
x := fn () string {
|
||||||
|
return 'ok'
|
||||||
|
}
|
||||||
|
return x()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_generic_fn_with_anon_fn() {
|
||||||
|
ret := foo<int>()
|
||||||
|
assert ret == 'ok'
|
||||||
|
}
|
Loading…
Reference in New Issue